Пример #1
0
 public void testPrintStackUpEmptyStack()
 {
     // ARRANGE
     StackLabCode.stack myStack = new StackLabCode.stack(1);
     // ACT
     // ASSERT
     Assert.Throws <StackLabCode.StackEmptyException>(() => myStack.printStackUp());
 }
Пример #2
0
        public void testCreateStack()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            bool actual;

            // ACT
            actual = myStack.isEmpty();
            // ASSERT
            Assert.True(actual);
        }
Пример #3
0
        public void testPushFullStack()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            string             item    = "StackItem";

            myStack.push(item);
            // ACT
            // ASSERT
            Assert.Throws <StackLabCode.StackFullException>(() => myStack.push(item));
        }
Пример #4
0
        public void testIsFullFalse()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            bool actual, expected;

            // ACT
            actual   = myStack.isFull();
            expected = false;
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #5
0
        public void testIsEmptyTrue()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            bool actual, expected;

            // ACT
            actual   = myStack.isEmpty();
            expected = true;
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #6
0
        public void testStackSizeZero()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(2);
            int actual, expected;

            expected = 0;
            // ACT
            actual = myStack.size();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #7
0
        public void testIsFullTrue()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            string             item = "Java is Fun!";
            bool actual, expected;

            // ACT
            myStack.push(item);
            actual   = myStack.isFull();
            expected = true;
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #8
0
        public void testPeekStack()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(1);
            string             item = "StackItem";
            string             actual, expected;

            // ACT
            myStack.push(item);
            expected = item;
            actual   = myStack.peek();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #9
0
        public void testStackSizeNonZero()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(2);
            string             item = "StackItem";
            int actual, expected;

            expected = 2;
            // ACT
            myStack.push(item + "1");
            myStack.push(item + "2");
            actual = myStack.size();
            // ASSERT
            Assert.Equal(expected, actual);
        }
Пример #10
0
        public void testPushStack()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(2);
            string             item = "StackItem";
            string             expected, actual;

            expected = "StackItem2";
            // ACT
            myStack.push(item + "1");
            myStack.push(item + "2");
            actual = myStack.peek();
            // ASSERT
            Assert.False(myStack.isEmpty());
            Assert.Equal(expected, actual);
        }
Пример #11
0
        public void testPrintStackUp()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(2);
            string             item = "StackItem";
            string             actual, expected;

            expected = "StackItem1\nStackItem2\n";
            // ACT
            myStack.push(item + "1");
            myStack.push(item + "2");
            actual = myStack.printStackUp();
            // ASSERT
            Assert.Equal(expected, actual);
            Assert.False(myStack.isEmpty());
        }
Пример #12
0
        public void testPopStack()
        {
            // ARRANGE
            StackLabCode.stack myStack = new StackLabCode.stack(2);
            string             item = "StackItem";
            string             actual1, actual2, expected1, expected2;

            expected1 = "StackItem2";
            expected2 = "StackItem1";
            myStack.push(item + "1");
            myStack.push(item + "2");
            // ACT
            actual1 = myStack.pop();
            actual2 = myStack.pop();
            // ASSERT
            Assert.Equal(expected1, actual1);
            Assert.Equal(expected2, actual2);
            Assert.True(myStack.isEmpty());
        }