public void LoopingList_EmptyList_YieldBreaksImmidiately() { var list = new LoopingList <int>(new List <int>()); var newList = list.ToList(); Assert.Equal(0, newList.Count); }
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); }
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(); } }
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); }