コード例 #1
0
        public void DoesPushAddElementWhenStackIsFull()
        {
            ArrayTypedStack stack = new ArrayTypedStack(2);

            stack.Push(2);
            stack.Push(3);
            stack.Push(4);
        }
コード例 #2
0
        public void DoesPopRemoveElementWhenStackIsNotEmpty()
        {
            ArrayTypedStack stack = new ArrayTypedStack(3);

            stack.Push(3);
            stack.Push(2);
            int actual   = (int)stack.Pop();
            int expected = 2;

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void DoesPopDecreasedSize()
        {
            ArrayTypedStack stack = new ArrayTypedStack(3);

            stack.Push(3);
            stack.Push(2);
            stack.Pop();
            int actual   = stack.Size;
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void DoesDisplayElementsPrintsCorrectly()
        {
            ArrayTypedStack stack = new ArrayTypedStack(3);

            stack.Push(1);
            stack.Push(2);
            stack.Push(3);

            string expected = "3 2 1 ";
            string actual   = stack.DisplayElements();

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void DoesPeekShowTopElementWhenStackIsNotEmpty()
        {
            ArrayTypedStack stack = new ArrayTypedStack(3);

            stack.Push(2);
            stack.Push(3);
            int actual   = (int)stack.Peek();
            int expected = 3;

            Assert.AreEqual(expected, actual);

            int actualSize   = stack.Size;
            int expectedSize = 2;

            Assert.AreEqual(expectedSize, actualSize);
        }
コード例 #6
0
        public void DoesPushAddElementWhenStackIsNotEmpty()
        {
            ArrayTypedStack stack = new ArrayTypedStack(3);

            stack.Push(3);
            stack.Push(2);

            string actual   = stack.DisplayElements();
            string expected = "2 3 ";

            Assert.AreEqual(expected, actual);

            int actualSize   = stack.Size;
            int expectedSize = 2;

            Assert.AreEqual(expectedSize, actualSize);
        }
コード例 #7
0
        public void DoesIsEmptyReturnFalseWhenStackIsNotEmpty()
        {
            ArrayTypedStack stack = new ArrayTypedStack(2);

            stack.Push(3);
            bool actualResult   = stack.IsEmpty();
            bool expectedResult = false;

            Assert.AreEqual(expectedResult, actualResult);
        }