@@ -203,6 +203,33 @@ public void CanDeserializeIntGenericDictionaryWithComplexType()
203
203
Assert . IsTrue ( prop . Dict [ 2 ] . Name == "b" ) ;
204
204
}
205
205
206
+ public class SortedListDictionary
207
+ {
208
+ public SortedList < string , int > Property { get ; set ; }
209
+ }
210
+
211
+ [ Test ]
212
+ public void CanSerializeSortedListDictionary ( )
213
+ {
214
+ var expectedBson = Serialize < Document > ( new Document ( "Property" , new Document { { "key1" , 10 } , { "key2" , 20 } } ) ) ;
215
+ var obj = new SortedListDictionary { Property = new SortedList < string , int > { { "key1" , 10 } , { "key2" , 20 } } } ;
216
+ var bson = Serialize < GenericDictionary > ( obj ) ;
217
+ Assert . AreEqual ( expectedBson , bson ) ;
218
+ }
219
+
220
+ [ Test ]
221
+ public void CanDeserializeSortedListDictionary ( )
222
+ {
223
+ var bson = Serialize < Document > ( new Document ( "Property" , new Document { { "key1" , 10 } , { "key2" , 20 } } ) ) ;
224
+ var prop = Deserialize < SortedListDictionary > ( bson ) ;
225
+
226
+ Assert . IsNotNull ( prop ) ;
227
+ Assert . IsNotNull ( prop . Property ) ;
228
+ Assert . AreEqual ( 2 , prop . Property . Count ) ;
229
+ Assert . Contains ( new KeyValuePair < string , int > ( "key1" , 10 ) , prop . Property ) ;
230
+ Assert . Contains ( new KeyValuePair < string , int > ( "key2" , 20 ) , prop . Property ) ;
231
+ }
232
+
206
233
public class HashSetHelper
207
234
{
208
235
public HashSet < string > Property { get ; set ; }
0 commit comments