public void Dequeue_From_Empty_Throws() { var queue = new CustomQueue.Queue <int>(); Should.Throw <InvalidOperationException>(() => { var poppedValue = queue.Dequeue(); } ); }
public void Peek_From_Empty_Throws_After_Enqueue() { var queue = new CustomQueue.Queue <int>(); queue.Enqueue(1); queue.Dequeue(); Should.Throw <InvalidOperationException>(() => { var poppedValue = queue.Peek(); } ); }
public void Queue_Success_Cases(int[] testData) { var queue = new CustomQueue.Queue <int>(); for (var i = 0; i < testData.Length; i++) { queue.Count.ShouldBe(i, "The queue count is off"); queue.Enqueue(testData[i]); queue.Count.ShouldBe(i + 1, "The queue count is off"); queue.Peek().ShouldBe(testData[0], "The recently pushed value is not peeking"); } queue.Count.ShouldBe(testData.Length, "The end count was not as expected"); var counter = 0; foreach (int value in queue) { value.ShouldBe(testData[counter], "The enumeration is not accurate"); counter++; } var expectedQueueSize = queue.Count; for (var item = 0; item < testData.Length; item++) { var expected = testData[item]; queue.Peek().ShouldBe(expected, "The peeked value was not expected"); queue.Dequeue().ShouldBe(expected, "The dequeued value was not expected"); expectedQueueSize--; queue.Count.ShouldBe(expectedQueueSize, "The dequeued value was not expected"); } }