public void TestEnqueue_OneItem() { CustomQueue <int> queue = new CustomQueue <int>(); queue.Enqueue(1); Assert.AreEqual(1, queue.Count); Assert.AreEqual("1", queue.ToString()); }
public void TestToString_NonEmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 5; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } Assert.AreEqual("01234", queue.ToString()); }
public void TestEnqueue_TenItems() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 10; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } Assert.AreEqual(queueCount, queue.Count); Assert.AreEqual("0123456789", queue.ToString()); }
public void TestDequeue_OneItem() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 5; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } int dequeuedItem = queue.Dequeue(); Assert.AreEqual(0, dequeuedItem); Assert.AreEqual(4, queue.Count); Assert.AreEqual("1234", queue.ToString()); }
public void TestToArray_NonEmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 10; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } int[] arr = queue.ToArray(); Assert.AreEqual(10, arr.Length); Assert.AreEqual(queue.Peek(), arr[0]); Assert.AreEqual(queue.ToString(), string.Join(string.Empty, arr)); }
public void TestClone_NonEmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 5; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } CustomQueue <int> clone = (CustomQueue <int>)queue.Clone(); queue.Dequeue(); Assert.AreEqual(5, clone.Count); Assert.AreEqual("01234", clone.ToString()); Assert.AreEqual(4, queue.Count); }
public void TestDequeue_MultipleItems() { CustomQueue <int> queue = new CustomQueue <int>(); int queueCount = 10; for (int i = 0; i < queueCount; i++) { queue.Enqueue(i); } for (int i = 0; i < 5; i++) { int dequeuedItem = queue.Dequeue(); Assert.AreEqual(i, dequeuedItem); } Assert.AreEqual(5, queue.Count); Assert.AreEqual("56789", queue.ToString()); }
public void TestToString_EmptyQueue() { CustomQueue <int> queue = new CustomQueue <int>(); Assert.AreEqual(string.Empty, queue.ToString()); }