public void VerifyPeekInQueue() { var actual = new QueueUsingArray(3); actual.Enqueue(12); actual.Enqueue(14); actual.Enqueue(16); Assert.AreEqual(3, actual.Count()); var value = actual.Peek(); Assert.AreEqual(12, value); Assert.AreEqual(3, actual.Count()); }
public void Peek() { QueueUsingArray <int> queue = new QueueUsingArray <int>(); queue.Enqueue(10); queue.Enqueue(20); queue.Enqueue(30); queue.Enqueue(40); //10 <- 20 <- 30 <- 40 queue.Dequeue(); queue.Dequeue(); //30 <- 40 Assert.AreEqual(queue.Peek(), 30); }