예제 #1
0
        public void should_composing_iterating_sequences()
        {
            var demoObject = new ImplIteratorUsingYieldDemoClass();
            var numberStorage = new List<int>();

            foreach (int number in demoObject.GetEvenNumber(demoObject.GetOneToTen()))
            {
                numberStorage.Add(number);
            }

            // change the variable value to fix the test.
            var expectedNumberStorage = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            Assert.Equal(expectedNumberStorage, numberStorage);
        }
예제 #2
0
        public void should_implement_iterator_using_yield()
        {
            var demoObject = new ImplIteratorUsingYieldDemoClass();
            var numberStorage = new List<int>();

            foreach (int number in demoObject.GetOneToTen())
            {
                numberStorage.Add(number);
            }

            // change the variable value to fix the test.
            var expectedNumberStorage = new List<int> {1, 2};

            Assert.Equal(expectedNumberStorage, numberStorage);
        }