示例#1
0
        public void VerifyEnumerator()
        {
            var sut = new ObjectArrayCollection();

            sut.Add(0);
            sut.Add(2.657);
            sut.Add("string");
            var enumerator = sut.GetEnumerator();

            enumerator.MoveNext();
            Assert.Equal(0, enumerator.Current);
            enumerator.MoveNext();
            enumerator.MoveNext();
            Assert.Equal("string", enumerator.Current);
        }
        public void TestForNumeratorInObjectArrayColection()
        {
            var array = new ObjectArrayCollection {
                (object)true, (object)false,
                (object)"string", (object)null,
                (object)string.Empty, (object)int.MaxValue,
                (object)float.MaxValue
            };

            var numerator = array.GetEnumerator();

            numerator.MoveNext();
            numerator.MoveNext();
            numerator.MoveNext();
            var current = numerator.Current;

            Assert.Equal("string", current);
            Assert.Equal(6, array.IndexOf(float.MaxValue));
            Assert.Equal(7, array.Count);
        }
        public void TestForNumerator_Move_Next_InObjectArrayColectionOutOfIndex()
        {
            var array = new ObjectArrayCollection {
                (object)true, (object)false,
                (object)"string", (object)null,
                (object)string.Empty, (object)int.MaxValue,
                (object)float.MaxValue
            };

            var numerator = array.GetEnumerator();

            for (int i = 0; i < 10; i++)
            {
                numerator.MoveNext();
            }

            var current = numerator.Current;

            Assert.Equal(array[array.Count - 1], current);
            Assert.Equal(6, array.IndexOf(float.MaxValue));
            Assert.Equal(7, array.Count);
        }