Пример #1
0
        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);
        }
Пример #2
0
        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);
        }