public void QueueWithArray_Peek_should_throw_exception_when_queue_is_empty() { try { qu.Peek(); Assert.Fail(); } catch (InvalidOperationException ex) { Assert.AreEqual("The queue is empty", ex.Message); } catch (Exception) { Assert.Fail(); } }
public void Enqueue_WhenCalled_ShouldAddItemToBackOfQueue(int capacity, int range) { // Arrange _queue = new QueueWithArray <int>(capacity); // Act for (var i = 1; i <= range; i++) { _queue.Enqueue(i); } // Assert Assert.That(_queue.Peek(), Is.EqualTo(1)); Assert.That(_queue.Size, Is.EqualTo(range)); }
public void Peek_WhenQueueIsEmpty_ShouldThrowInvalidOperationException() { // Arrange & Act & Assert Assert.Throws <InvalidOperationException>(() => _queue.Peek()); }