public void Queue_Foreach_Test() { var iterator = queue.GetEnumerator(); iterator.MoveNext(); Assert.AreEqual("one", iterator.Current); iterator.MoveNext(); Assert.AreEqual("two", iterator.Current); iterator.MoveNext(); Assert.AreEqual("last", iterator.Current); Assert.IsTrue(queue.Count == 3); }
public void TestMethodsEnqueuDequeuPeek(int[] expectedArray, int expectedPeek) { CustomQueue<int> customQueue = new CustomQueue<int>(); var customIter = customQueue.GetEnumerator(); Queue<int> queue = new Queue<int>(); customQueue.Enqueue(1); customQueue.Enqueue(2); customQueue.Enqueue(4); customQueue.Enqueue(8); customQueue.Enqueue(9); customQueue.Dequeue(); Assert.AreEqual(customQueue.Peek(), expectedPeek); int[] array = customQueue.ToArray(); CollectionAssert.AreEqual(expectedArray, array); }