public void Peek_OnStackWithItems_ReturnsLastAdded() { //Near-arbitrary stack size for the creation of the stack: int stackTestSize = 5; Stack target = new Stack(stackTestSize); //Push stub data to stack target.Push("A"); target.Push("B"); target.Push("C"); string expected = "C"; string actual = target.Peek(); Assert.AreEqual(expected, actual); }
public void Peek_OnFilledThenEmptiedStack_ReturnCorrectItem() { //Assemble int stackTestSize = 3; Stack target = new Stack(stackTestSize); //Act target.Push("A"); target.Push("B"); target.Push("C"); //Pop all but one item from the stack. target.Pop(); target.Pop(); string expected = target.Peek(); string actual = "A"; //Assert Assert.AreEqual(expected, actual); }
public void Peek_OnFullStackArray_ReturnCorrectItem() { //Assemble int stackTestSize = 2; Stack target = new Stack(stackTestSize); //Act target.Push("a"); target.Push("B"); string expected = target.Peek(); string actual = "B"; //Assert Assert.AreEqual(expected, actual); }
public void Peek_OnEmptyStack_ReturnsExceptionHandler() { //Near-arbitrary stack size for the creation of the stack: int stackTestSize = 5; Stack target = new Stack(stackTestSize); //Peek on an empty stack - will throw an exception in the test. target.Peek(); }