public static void DequeueEmptyQueueThrowsInvalidOperationException() { // Arrange var q = new StackBasedQueue <int>(); Exception?exception = null; // Act try { q.Dequeue(); } catch (Exception ex) { exception = ex; } // Assert Assert.AreEqual(typeof(InvalidOperationException), exception?.GetType()); }
public static void DequeueWorksCorrectly() { // Arrange var q = new StackBasedQueue <char>(); q.Enqueue('A'); q.Enqueue('B'); q.Enqueue('C'); var result = new StringBuilder(); // Act for (var i = 0; i < 3; i++) { result.Append(q.Dequeue()); } // Assert Assert.AreEqual("ABC", result.ToString()); Assert.IsTrue(q.IsEmpty(), "Queue is empty"); Assert.IsFalse(q.IsFull(), "Queue is full"); }