public void ShouldReturnItemsInRevertedOrderThanWasInserted() { var items = new List <int> { 18, 5, -6, 36, 48 }; var expectedList = new List <int>(items); expectedList.Reverse(); var cut = new ListBasedStackImplementation <int>(items.Capacity); items.ForEach(item => cut.Push(item)); expectedList.ForEach(expectedItem => { Assert.AreEqual(expectedItem, cut.Pop()); }); }
public void ShouldReturnDifferentSizeWhenPop() { var cut = new ListBasedStackImplementation <int>(10); var items = new List <int> { 18, 5, -6, 36, 48 }; items.ForEach(item => cut.Push(item)); var size = cut.CurrentSize; do { cut.Pop(); size--; Assert.AreEqual(size, cut.CurrentSize); }while (size > 0); }
public void ShouldThrowExceptionWhenPopOnEmptyStack() { var cut = new ListBasedStackImplementation <int>(1); var item = cut.Pop(); }