public void QueueViaStacks1SimpleCompleteTest2() { // Allocate queue. var q = new QueueViaStacks1SimpleComplete <int>(); // Check count. Assert.AreEqual(0, q.Count); // Enqueue q.Enqueue(5); q.Enqueue(10); // Check count. Assert.AreEqual(2, q.Count); // Peek Assert.AreEqual(5, q.Peek()); // Dequeue Assert.AreEqual(5, q.Dequeue()); // Check count. Assert.AreEqual(1, q.Count); // Peek Assert.AreEqual(10, q.Peek()); // Dequeue Assert.AreEqual(10, q.Dequeue()); // Check count. Assert.AreEqual(0, q.Count); }
public void QueueViaStacks1SimpleCompleteErrorTestDequeueEmptyQueue() { // Allocate queue. var q = new QueueViaStacks1SimpleComplete <int>(); try { q.Dequeue(); } catch (InvalidOperationException) { Assert.IsTrue(true); return; } // Should not get here. Assert.Fail(); }