public void Pop_EmptyStack_ThrowsException() { var stack = new MyStack <int>(); Assert.ThrowsException <InvalidOperationException>(() => { stack.Pop(); }); }
public void Peek_PushTwoItemsAndPop_ReturnsHeadElement() { var stack = new MyStack <int>(); stack.Push(1); stack.Push(2); stack.Pop(); Assert.AreEqual(1, stack.Peek()); }
public void It_Should_Throw_InvalidOperationException_When_PoppingAnEmptyStack() { //arrange var stack = new MyStack(); //act Action actual = () => stack.Pop(); //assert var exception = Assert.Throws <InvalidOperationException>(actual); Assert.Equal("Cannot remove item from an empty stack", exception.Message); }
public void It_Should_RemoveAnObject_WhenPopped() { //arrange var stack = new MyStack(); stack.Push(1); stack.Push(2); //act stack.Pop(); //assert Assert.Single(stack.Stack); }
public void It_Should_ReturnLastObject_WhenPopped() { //arrange var stack = new MyStack(); stack.Push(1); stack.Push(2); stack.Push(3); //act var poppedItem = stack.Pop(); //assert Assert.StrictEqual(3, poppedItem); }