public void Peek() { Assert.AreEqual(new CloneableType("three"), _stack.Peek()); Assert.AreEqual(new CloneableType("three"), _stack.Peek()); _stack.Pop(); Assert.AreEqual(new CloneableType("two"), _stack.Peek()); _stack.Clear(); Assert.Throws <InvalidOperationException>(() => _stack.Peek()); }
public void ShouldMoveDuplicateItemToTopOfList(string[] stringsToPush, string expectedString, int expectedCount) { StringStack stringStack = new StringStack(stringsToPush); Assert.AreEqual(expectedString, stringStack.Peek()); Assert.AreEqual(expectedCount, stringStack.Count); }
public void ShouldRemoveOldestStringWhenAtCapacityAndNewStringIsAdded() { StringStack stringStack = new StringStack(3); stringStack.Push("apple"); stringStack.Push("orange"); stringStack.Push("pineapple"); stringStack.Push("pear"); Assert.AreEqual(3, stringStack.Count); Assert.AreEqual("pear", stringStack.Peek()); }
public void ShouldReturnMostRecentlyAddedStringAsTopItem(string[] stringsToPush, string expected) { StringStack stringStack = new StringStack(stringsToPush); Assert.AreEqual(expected, stringStack.Peek()); }