Ejemplo n.º 1
0
        public static void Reset()
        {
            // Arrange
            var value = new AnyT();

            using var seq = new YieldForever <AnyT>(value);

            // Act
            IEnumerator it = seq.GetEnumerator();

            // Assert
            for (int i = 0; i < 100; i++)
            {
                Assert.True(it.MoveNext());
                Assert.Same(value, it.Current);
            }

            // Reset() does nothing.
            it.Reset();

            for (int i = 0; i < 100; i++)
            {
                Assert.True(it.MoveNext());
                Assert.Same(value, it.Current);
            }
        }
Ejemplo n.º 2
0
        public static void MoveNext()
        {
            // Arrange
            using var seq = new YieldForever <AnyT>(new AnyT());
            // Act
            IEnumerator it = seq.GetEnumerator();

            // Assert
            Assert.True(it.MoveNext());
        }
Ejemplo n.º 3
0
        public static void GetEnumerator()
        {
            // Arrange
            using var seq = new YieldForever <AnyT>(new AnyT());
            // Act
            IEnumerator <AnyT> it = seq.GetEnumerator();

            // Assert
            Assert.Same(seq, it);
        }
Ejemplo n.º 4
0
        public static void GetEnumerator_Untyped()
        {
            // Arrange
            using var seq = new YieldForever <AnyT>(new AnyT());
            // Act
            IEnumerable enumerable = seq;
            IEnumerator it         = enumerable.GetEnumerator();

            // Assert
            Assert.Same(seq, it);
        }
Ejemplo n.º 5
0
        public static void Current_Untyped()
        {
            // Arrange
            var value = new AnyT();

            using var seq = new YieldForever <AnyT>(value);

            // Act
            IEnumerator it = seq.GetEnumerator();

            // Assert
            // Even before the first MoveNext(), Current already returns "value".
            Assert.Same(value, it.Current);

            for (int i = 0; i < 100; i++)
            {
                Assert.True(it.MoveNext());
                Assert.Same(value, it.Current);
            }
        }