Example #1
0
        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());
        }
Example #2
0
        public void ShouldMoveDuplicateItemToTopOfList(string[] stringsToPush, string expectedString, int expectedCount)
        {
            StringStack stringStack = new StringStack(stringsToPush);

            Assert.AreEqual(expectedString, stringStack.Peek());
            Assert.AreEqual(expectedCount, stringStack.Count);
        }
Example #3
0
        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());
        }
Example #4
0
        public void ShouldReturnMostRecentlyAddedStringAsTopItem(string[] stringsToPush, string expected)
        {
            StringStack stringStack = new StringStack(stringsToPush);

            Assert.AreEqual(expected, stringStack.Peek());
        }