示例#1
0
        public void LoopingList_EmptyList_YieldBreaksImmidiately()
        {
            var list = new LoopingList <int>(new List <int>());

            var newList = list.ToList();

            Assert.Equal(0, newList.Count);
        }
示例#2
0
        public void LoopingList_TakeTons_NeverYieldBreaks()
        {
            var list = new LoopingList <int>(new List <int> {
                1, 2, 3
            });

            //As mentioned previously take will short circuit if a yield break occurs
            var newList = list.Take(100).ToList();

            Assert.Equal(100, newList.Count);
            Assert.Contains(1, newList);
            Assert.Contains(2, newList);
            Assert.Contains(3, newList);
        }
示例#3
0
        public void RepeatingList_WhenOverExtendsTheUnderlyingEnumerator_ExceptionThrown()
        {
            var list = new LoopingList <int>(new List <int> {
                1, 2, 3
            });

            //another way you can test this is by using the underlying IEnumerator interface
            var enumerator = list.GetEnumerator();

            for (int i = 0; i < 7; i++)
            {
                enumerator.MoveNext();
            }
        }
示例#4
0
        public void LoopingList_UsingUnderlyingEnumerator_NeverThrowsException()
        {
            var list = new LoopingList <int>(new List <int> {
                1, 2, 3
            });

            //another way you can test this is by using the underlying IEnumerator interface
            var newList    = new List <int>();
            var enumerator = list.GetEnumerator();

            for (int i = 0; i < 100; i++)
            {
                newList.Add(enumerator.Current);
                enumerator.MoveNext();
            }

            Assert.Equal(100, newList.Count);
        }