public void IteratesIDictionaryKV() { dynamic dict = new ExpandoObject(); // Implements IDictionary<string, object>, but not IDictionary dict.k1 = 1; dict.k2 = "v2"; var actual = DictionaryIterator.Iterate((object)dict).OrderBy(x => x.Key).ToList(); var expected = new List <KeyValuePair <object, object> >() { new KeyValuePair <object, object>("k1", 1), new KeyValuePair <object, object>("k2", "v2"), }; Assert.Equal(expected, actual); }
public void IteratesIDictionary() { var dict = new Hashtable() { { "k1", 1 }, { "k2", "v2" } }; var actual = DictionaryIterator.Iterate(dict).OrderBy(x => x.Key).ToList(); var expected = new List <KeyValuePair <object, object> >() { new KeyValuePair <object, object>("k1", 1), new KeyValuePair <object, object>("k2", "v2"), }; Assert.Equal(expected, actual); }