From 91f770adf36407b4fb00bcc984e15e9210d16120 Mon Sep 17 00:00:00 2001 From: Steve Wagner Date: Fri, 18 Jun 2010 14:12:12 +0200 Subject: [PATCH] Add failing SortedList serialization and deserialization tests. --- .../SerializationFactoryTests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source/MongoDB.Tests/UnitTests/Serialization/SerializationFactoryTests.cs b/source/MongoDB.Tests/UnitTests/Serialization/SerializationFactoryTests.cs index 5920779c..5c978ee7 100644 --- a/source/MongoDB.Tests/UnitTests/Serialization/SerializationFactoryTests.cs +++ b/source/MongoDB.Tests/UnitTests/Serialization/SerializationFactoryTests.cs @@ -203,6 +203,33 @@ public void CanDeserializeIntGenericDictionaryWithComplexType() Assert.IsTrue(prop.Dict[2].Name == "b"); } + public class SortedListDictionary + { + public SortedList Property { get; set; } + } + + [Test] + public void CanSerializeSortedListDictionary() + { + var expectedBson = Serialize(new Document("Property", new Document { { "key1", 10 }, { "key2", 20 } })); + var obj = new SortedListDictionary { Property = new SortedList { { "key1", 10 }, { "key2", 20 } } }; + var bson = Serialize(obj); + Assert.AreEqual(expectedBson, bson); + } + + [Test] + public void CanDeserializeSortedListDictionary() + { + var bson = Serialize(new Document("Property", new Document { { "key1", 10 }, { "key2", 20 } })); + var prop = Deserialize(bson); + + Assert.IsNotNull(prop); + Assert.IsNotNull(prop.Property); + Assert.AreEqual(2, prop.Property.Count); + Assert.Contains(new KeyValuePair("key1", 10), prop.Property); + Assert.Contains(new KeyValuePair("key2", 20), prop.Property); + } + public class HashSetHelper { public HashSet Property { get; set; }