public static void Stepper_Testing <TQueue>() where TQueue : IQueue <int>, new() { { // enqueue only int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); Assert.IsTrue(queue.Count == values.Length); ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; int[] expectedValues = { 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); queue.Dequeue(); queue.Dequeue(); Assert.IsTrue(queue.Count == expectedValues.Length); ISet <int> set = SetHashLinked.New <int>(); expectedValues.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } { // enqueue + dequeue int[] values = { 0, 1, 2, 3, 4, 5, }; IQueue <int> queue = new TQueue(); values.Stepper(i => queue.Enqueue(i)); values.Stepper(i => { queue.Dequeue(); queue.Enqueue(i); }); Assert.IsTrue(queue.Count == values.Length); ISet <int> set = SetHashLinked.New <int>(); values.Stepper(i => set.Add(i)); queue.Stepper(i => { Assert.IsTrue(set.Contains(i)); set.Remove(i); }); Assert.IsTrue(set.Count == 0); } }