public static void PeekEmptyQueueThrowsInvalidOperationException() { // Arrange var q = new StackBasedQueue <int>(); Exception?exception = null; // Act try { q.Peek(); } catch (Exception ex) { exception = ex; } // Assert Assert.AreEqual(typeof(InvalidOperationException), exception?.GetType()); }
public static void PeekWorksCorrectly() { // Arrange var q = new StackBasedQueue <int>(); q.Enqueue(1); q.Enqueue(2); var peeked = 0; // Act for (var i = 0; i < 3; i++) { peeked = q.Peek(); } // Assert Assert.AreEqual(1, peeked); Assert.IsFalse(q.IsEmpty(), "Queue is empty"); Assert.IsFalse(q.IsFull(), "Queue is full"); }