示例#1
0
        public void Stack_Count_ReturnsZeroIfStackIsEmpty()
        {
            Stack stack = new Stack();
            int expectedNumberOfItems = 0;

            int stackCountValue = stack.Count();

            Assert.AreEqual(expectedNumberOfItems, stackCountValue);
        }
示例#2
0
        public void Stack_Count_ReturnsZeroIfPreviouslyPopulatedStackIsEmpty()
        {
            Stack stack = new Stack();
            int expectedNumberOfItems = 0;

            stack.Push("Some data");
            stack.Pop();

            int stackCountValue = stack.Count();

            Assert.AreEqual(expectedNumberOfItems, stackCountValue);
        }
示例#3
0
        public void Stack_Count_ReturnsCorrectNumberOfItems()
        {
            Stack stack = new Stack();
            int expectedNumberOfItems = 4;

            stack.Push("Data");
            stack.Push("More data");
            stack.Push("Even more data");
            stack.Push("DATA");

            int actualNumberOfItems = stack.Count();

            Assert.AreEqual(expectedNumberOfItems, actualNumberOfItems);
        }
示例#4
0
        public void Stack_Count_ReturnsCorrectNumberOfItemsAfterMultiplePops()
        {
            Stack stack = new Stack();
            int expectedNumberOfItems = 2;

            stack.Push("Data");
            stack.Push("More data");
            stack.Push("Even more data");
            stack.Push("DATA");
            stack.Push("DATAAA!!!!!");

            stack.Pop();
            stack.Pop();
            stack.Pop();

            int numberOfItemsAfterMultiplePops = stack.Count();

            Assert.AreEqual(expectedNumberOfItems, numberOfItemsAfterMultiplePops);
        }
示例#5
0
        public void Stack_Push_MultipleItemsToStackAfterMultiplePops()
        {
            Stack stack = new Stack();
            int expectedStackCount = 3;

            stack.Push("First item");
            stack.Push("Second item");
            stack.Push("Third item");

            stack.Pop();
            stack.Pop();

            stack.Push("Hello");
            stack.Push("Last item");

            int actualStackCount = stack.Count();

            Assert.AreEqual(expectedStackCount, actualStackCount);
        }
示例#6
0
        public void Stack_Push_MultipleItemsToEmptyStack()
        {
            Stack stack = new Stack();
            int expectedStackCount = 3;

            stack.Push("First item");
            stack.Push("Second item");
            stack.Push("Third item");

            int actualStackCount = stack.Count();

            Assert.AreEqual(expectedStackCount, actualStackCount);
        }
示例#7
0
        public void Stack_Push_ItemToPreviouslyPopulatedEmptyStack()
        {
            Stack stack = new Stack();
            int expectedStackCount = 1;

            stack.Push("This is a string :)");
            stack.Push("This is another string :)");

            stack.Pop();
            stack.Pop();

            stack.Push("Some data");

            int actualStackCount = stack.Count();

            Assert.AreEqual(expectedStackCount, actualStackCount);
        }
示例#8
0
        public void Stack_Push_ItemToEmptyStack()
        {
            Stack stack = new Stack();
            int expectedStackCount = 1;

            stack.Push("This is a string :)");

            int actualStackCount = stack.Count();

            Assert.AreEqual(expectedStackCount, actualStackCount);
        }
示例#9
0
        public void Stack_Pop_RemovesNodeFromStackWithOnlyOneNode()
        {
            Stack stack = new Stack();
            int expectedCount = 0;

            stack.Push("Item to be popped");
            stack.Pop();

            int actualCount = stack.Count();

            Assert.AreEqual(expectedCount, actualCount);
        }
示例#10
0
        public void Stack_Peek_DoesntRemoveNode()
        {
            Stack stack = new Stack();

            stack.Push("First Item");
            stack.Push("Second Item");

            int countBeforePeeking = stack.Count();

            stack.Peek();

            int countAfterPeeking = stack.Count();

            Assert.AreEqual(countBeforePeeking, countAfterPeeking);
        }