summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-01-13 17:32:21 -0800
committerAndrew <andrewarnott@gmail.com>2009-01-13 17:32:21 -0800
commitb91d5c485e4d6cdbd5048228dd9c8fd7119274c1 (patch)
tree6d0b7487e445db78a06d529581f564123ce06e6d /src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
parent5f2973e785be54fdafaa8907d44fba669dd392d8 (diff)
downloadDotNetOpenAuth-b91d5c485e4d6cdbd5048228dd9c8fd7119274c1.zip
DotNetOpenAuth-b91d5c485e4d6cdbd5048228dd9c8fd7119274c1.tar.gz
DotNetOpenAuth-b91d5c485e4d6cdbd5048228dd9c8fd7119274c1.tar.bz2
Fixes null key handling in incoming query strings.
Fixes Google Code Issue 9 on dotnetoauth project.
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));