Enhance dictionary safety with SafeGet, SafeSet, and SafeRemove methods. Adjust IWebContext and related tests to support nullable value types in dictionary operations. Refactor GetRequestParameter for clarity and consistency.

This commit is contained in:
2025-07-29 02:05:28 +02:00
parent bab8898841
commit b7b7c472af
12 changed files with 55 additions and 34 deletions

View File

@@ -38,7 +38,7 @@ public class ExtensionMethodsTests
FakeWebContext fakeWebContext = new();
string key = "Key";
string value = "Value";
fakeWebContext.RequestQuery.Add(key, value);
fakeWebContext.RequestQuery.SafeSet(key, value);
string result = fakeWebContext.GetRequestParameter(key);
@@ -52,7 +52,7 @@ public class ExtensionMethodsTests
FakeWebContext fakeWebContext = new(requestMethod: "POST");
string key = "Key";
string value = "Value";
fakeWebContext.RequestForm.Add(key, value);
fakeWebContext.RequestForm.SafeSet(key, value);
string result = fakeWebContext.GetRequestParameter(key);
@@ -67,7 +67,7 @@ public class ExtensionMethodsTests
string keyInvalid = "KeyInvalid";
string key = "Key";
string value = "Value";
fakeWebContext.RequestQuery.Add(keyInvalid, value);
fakeWebContext.RequestQuery.SafeSet(keyInvalid, value);
string result = fakeWebContext.GetRequestParameter(key);
@@ -82,7 +82,7 @@ public class ExtensionMethodsTests
string keyInvalid = "KeyInvalid";
string key = "Key";
string value = "Value";
fakeWebContext.RequestForm.Add(keyInvalid, value);
fakeWebContext.RequestForm.SafeSet(keyInvalid, value);
string result = fakeWebContext.GetRequestParameter(key);