public static void ClearWorksCorrectly() { // Arrange var q = new ListBasedQueue <int>(); q.Enqueue(1); q.Enqueue(2); // Act q.Clear(); // Assert Assert.IsTrue(q.IsEmpty(), "Queue is empty"); Assert.IsFalse(q.IsFull(), "Queue is full"); }
public static void PeekWorksCorrectly() { // Arrange var q = new ListBasedQueue <int>(); q.Enqueue(1); q.Enqueue(2); int peeked = 0; // Act for (int i = 0; i < 3; i++) { peeked = q.Peek(); } // Assert Assert.AreEqual(expected: 1, actual: peeked); Assert.IsFalse(q.IsEmpty(), "Queue is empty"); Assert.IsFalse(q.IsFull(), "Queue is full"); }
public static void DequeueWorksCorrectly() { // Arrange var q = new ListBasedQueue <char>(); q.Enqueue('A'); q.Enqueue('B'); q.Enqueue('C'); var result = new StringBuilder(); // Act for (int i = 0; i < 3; i++) { result.Append(q.Dequeue()); } // Assert Assert.AreEqual(expected: "ABC", actual: result.ToString()); Assert.IsTrue(q.IsEmpty(), "Queue is empty"); Assert.IsFalse(q.IsFull(), "Queue is full"); }