public void Cycle () { // not entirely sure how you sanely test an infinite list... var x = new[]{1}; Assert.AreEqual ("1,1,1,1,1", x.Cycle ().Take (5).Implode (",")); x = new[]{1, 2, 3}; Assert.AreEqual ("1,2,3,1,2,3,1,2,3,1,2,3,1,2,3", x.Cycle ().Take (3*5).Implode (",")); }
public void Cycle() { var array = new[] { 0, 1, 2, 3 }; var index = 0; foreach (var item in array.Cycle()) { Assert.AreEqual(item, index % 4); index++; // Cycle is an infinite loop - we need a way out if (index > 20) { break; } } }