Example #1
0
        public void SingleTest()
        {
            IteratorPattern.LinkedListNode <int>     head     = new IteratorPattern.LinkedListNode <int>(1);
            IteratorPattern.LinkedListSequence <int> sequence = new IteratorPattern.LinkedListSequence <int>(head);
            List <int> list = new List <int>();

            foreach (int value in sequence)
            {
                list.Add(value);
            }

            Assert.AreEqual(1, list.Single());
        }
Example #2
0
        public void MultipleTest()
        {
            IteratorPattern.LinkedListNode <int>     head     = new IteratorPattern.LinkedListNode <int>(0, new IteratorPattern.LinkedListNode <int>(1, new IteratorPattern.LinkedListNode <int>(2, new IteratorPattern.LinkedListNode <int>(3))));
            IteratorPattern.LinkedListSequence <int> sequence = new IteratorPattern.LinkedListSequence <int>(head);
            List <int> list = new List <int>();

            foreach (int value in sequence)
            {
                list.Add(value);
            }

            EnumerableAssert.AreSequentialEqual(new int[] { 0, 1, 2, 3 }, list);
        }
Example #3
0
        public void EmptyTest()
        {
            IteratorPattern.LinkedListNode <int>     head     = null;
            IteratorPattern.LinkedListSequence <int> sequence = new IteratorPattern.LinkedListSequence <int>(head);
            List <int> list = new List <int>();

            foreach (int value in sequence)
            {
                list.Add(value);
            }

            Assert.IsFalse(list.Any());
        }