public void EnqueueAndDequeueTest_ValueType() { IQueue <int> queue = new ResizingArrayQueue <int>(); queue.Enqueue(1); Assert.IsFalse(queue.IsEmpty()); Assert.AreEqual(1, queue.Peek()); Assert.AreEqual(1, queue.Size()); int value = queue.Dequeue(); Assert.IsTrue(queue.IsEmpty()); Assert.AreEqual(0, queue.Size()); Assert.AreEqual(1, value); }
public void EnqueueAndDequeueTest_ReferenceType() { IQueue <String> queue = new ResizingArrayQueue <String>(); queue.Enqueue("1"); Assert.IsFalse(queue.IsEmpty()); Assert.AreEqual("1", queue.Peek()); Assert.AreEqual(1, queue.Size()); String value = queue.Dequeue(); Assert.IsTrue(queue.IsEmpty()); Assert.AreEqual(0, queue.Size()); Assert.AreEqual("1", value); }
public void ConstructorTest() { IQueue <int> queue = new ResizingArrayQueue <int>(); Assert.IsTrue(queue.IsEmpty()); Assert.AreEqual(0, queue.Size()); Assert.IsTrue(string.IsNullOrWhiteSpace(queue.ToString())); }
public void ManyEnqueueTest() { IQueue <int> queue = new ResizingArrayQueue <int>(); for (int i = 0; i < 10; i++) { queue.Enqueue(i); Assert.IsFalse(queue.IsEmpty()); Assert.AreEqual(i + 1, queue.Size()); Assert.AreEqual(0, queue.Peek()); } }