summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs')
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
index fc60ef6..782ce0d 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
@@ -64,12 +64,31 @@ namespace DotNetOpenAuth.Test.Messaging
NameValueCollection nvc = new NameValueCollection();
nvc["a"] = "b";
nvc["c"] = "d";
+ nvc[string.Empty] = "emptykey";
Dictionary<string, string> actual = MessagingUtilities.ToDictionary(nvc);
Assert.AreEqual(nvc.Count, actual.Count);
Assert.AreEqual(nvc["a"], actual["a"]);
Assert.AreEqual(nvc["c"], actual["c"]);
}
+ [TestMethod, ExpectedException(typeof(ArgumentException))]
+ public void ToDictionaryWithNullKey() {
+ NameValueCollection nvc = new NameValueCollection();
+ nvc[null] = "a";
+ nvc["b"] = "c";
+ nvc.ToDictionary(true);
+ }
+
+ [TestMethod]
+ public void ToDictionaryWithSkippedNullKey() {
+ NameValueCollection nvc = new NameValueCollection();
+ nvc[null] = "a";
+ nvc["b"] = "c";
+ var dictionary = nvc.ToDictionary(false);
+ Assert.AreEqual(1, dictionary.Count);
+ Assert.AreEqual(nvc["b"], dictionary["b"]);
+ }
+
[TestMethod]
public void ToDictionaryNull() {
Assert.IsNull(MessagingUtilities.ToDictionary(null));