public void ShouldThrowExceptionWhenPushOnExceededSize() { var cut = new ListBasedStackImplementation <int>(1); cut.Push(3); cut.Push(12); }
public void ShouldReturnDifferentSizeWhenPush() { var cut = new ListBasedStackImplementation <int>(10); var items = new List <int> { 18, 5, -6, 36, 48 }; for (int i = 0; i < items.Count; i++) { cut.Push(items[i]); Assert.AreEqual(i + 1, cut.CurrentSize); } }
public void ShouldReturnSameSizeWhenPeek() { var cut = new ListBasedStackImplementation <int>(10); var items = new List <int> { 18, 5, -6, 36, 48 }; items.ForEach(item => cut.Push(item)); foreach (var item in items) { Assert.AreEqual(items.Last(), cut.Peek()); Assert.AreEqual(items.Count, cut.CurrentSize); } }
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); }