示例#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);
            }
        }
示例#2
0
        public static void Ident()
        {
            // Arrange
            var value = new AnyT();

            // Act & Assert
            Assert.Same(Thunks <AnyT> .Ident, Thunks <AnyT> .Ident);
            Assert.NotNull(Thunks <AnyT> .Ident);
            Assert.Same(value, Thunks <AnyT> .Ident.Invoke(value));
        }
示例#3
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);
            }
        }