Ejemplo n.º 1
0
        public void When_getting_enumerator_as_ienumerable()
        {
            var p1 = new Person("A", 1);
            var p2 = new Person("B", 2);

            IEnumerable dic = new EasyDictionary <string, Person>(p => p.Id)
            {
                p1,
                p2
            };

            var enumerator = dic.GetEnumerator();

            enumerator.ShouldNotBeNull();

            enumerator.MoveNext().ShouldBeTrue();

            ((KeyValuePair <string, Person>)enumerator.Current).Key.ShouldBe("A");
            ((KeyValuePair <string, Person>)enumerator.Current).Value.ShouldBe(p1);

            enumerator.MoveNext().ShouldBeTrue();

            ((KeyValuePair <string, Person>)enumerator.Current).Key.ShouldBe("B");
            ((KeyValuePair <string, Person>)enumerator.Current).Value.ShouldBe(p2);

            enumerator.MoveNext().ShouldBeFalse();
        }
Ejemplo n.º 2
0
        public void When_getting_enumerator_as_easy_dictionary()
        {
            var p1 = new Person("A", 1);
            var p2 = new Person("B", 2);

            EasyDictionary <string, Person> dic = new EasyDictionary <string, Person>(p => p.Id)
            {
                p1,
                p2
            };

            using (var enumerator = dic.GetEnumerator())
            {
                enumerator.ShouldNotBeNull();

                enumerator.MoveNext().ShouldBeTrue();

                enumerator.Current.ShouldBe(p1);

                enumerator.MoveNext().ShouldBeTrue();

                enumerator.Current.ShouldBe(p2);

                enumerator.MoveNext().ShouldBeFalse();
            }
        }