Ejemplo n.º 1
0
        public void Count_OnEmptyStack_ReturnsZero()
        {
            //Near-arbitrary stack size for the creation of the stack:
            int stackTestSize = 5;
            Stack target = new Stack(stackTestSize);

            int expected = 0;
            int actual = target.Count();

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void Count_OnFilledThenEmptiedStack_ReturnsOne()
        {
            //Assemble
            int stackTestSize = 3;
            Stack target = new Stack(stackTestSize);

            //Act
            target.Push("A");
            target.Push("B");

            //Pop all but one item from the stack.
            target.Pop();

            //Verify that count has returned value of 1.
            int expected = 1;
            int actual = target.Count();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void Count_OnFilledMinusOneStack_ReturnsFour()
        {
            //Assemble
            int stackTestSize = 5;
            Stack target = new Stack(stackTestSize);

            //Act
            target.Push("A");
            target.Push("B");
            target.Push("C");
            target.Push("D");
            target.Push("E");

            //Pop the last item from the stack.
            target.Pop();

            //Verify that count has returned value of 4.
            int expected = 4;
            int actual = target.Count();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void Count_OnStackWithItems_ReturnsTwo()
        {
            //Near-arbitrary stack size for the creation of the stack:
            int stackTestSize = 5;
            Stack target = new Stack(stackTestSize);

            //Push stub data
            target.Push("a");
            target.Push("a");

            int expected = 2;
            int actual = target.Count();

            Assert.AreEqual(expected, actual);
        }