public void TestPush() { IStack <int> sut = new SinglyLinkedListStack <int>(); Assert.Throws <IndexOutOfRangeException>(() => sut.Top()); sut.Push(3); Assert.Equal(3, sut.Top()); sut.Push(4); sut.Push(5); Assert.Equal(5, sut.Top()); }
public void TestPop() { IStack <int> sut = new SinglyLinkedListStack <int>(); sut.Push(1); sut.Push(2); sut.Push(3); sut.Push(4); Assert.Equal(4, sut.Pop()); Assert.Equal(3, sut.Top()); sut.Pop(); sut.Pop(); Assert.Equal(1, sut.Pop()); Assert.True(sut.IsEmpty()); }