public void RepeatingList_EmptyList_YieldBreaksImmidiately() { var list = new RepeatingList <int>(new List <int>()); //to list call will iterator through the ienumerable until it hits a yield break var newList = list.ToList(); Assert.Equal(0, newList.Count); }
public void RepeatingList_IteratoringThroughIt_GoesThroughItTwice() { var list = new RepeatingList <int>(new List <int> { 1, 2, 3 }); //Take will short circuit if a yield break happens during it var newList = list.Take(7).ToList(); Assert.Equal(6, newList.Count); Assert.Equal(2, newList.Count(x => x == 1)); Assert.Equal(2, newList.Count(x => x == 2)); Assert.Equal(2, newList.Count(x => x == 3)); }