Esempio n. 1
0
        public void EnumerateAfterReset()
        {
            while (_enumerator.MoveNext())
            {
            }

            _enumerator.Reset();

            var counter = 0;

            while (_enumerator.MoveNext())
            {
                _array[counter++].Should().Be(_enumerator.Current);
            }

            counter.Should().Be(_array.Length);
        }
        public void TestArrayEnumerator__Reset()
        {
            string[] arr = { "abc", "def" };

            IEnumerator <string> enumerator = new ArrayEnumerator <string>(arr);

            Assert.True(enumerator.MoveNext());
            Assert.Equal("abc", enumerator.Current);
            Assert.True(enumerator.MoveNext());
            Assert.Equal("def", enumerator.Current);
            Assert.False(enumerator.MoveNext());

            enumerator.Reset();

            Assert.True(enumerator.MoveNext());
            Assert.Equal("abc", enumerator.Current);
            Assert.True(enumerator.MoveNext());
            Assert.Equal("def", enumerator.Current);
            Assert.False(enumerator.MoveNext());
        }