예제 #1
0
        public void _3_1_ThreeStack_WithTooManyPopsTestCases_ShouldThrowException(int eachStackSize, int stackNumber)
        {
            ThreeStackFixedSize threeStack = new ThreeStackFixedSize(eachStackSize);

            for (int i = 0; i < eachStackSize; i++)
            {
                threeStack.Push(stackNumber, i);
            }

            for (int i = 0; i < eachStackSize; i++)
            {
                threeStack.Pop(stackNumber);
            }

            Assert.Throws <Exception>(() => threeStack.Pop(stackNumber));
        }
예제 #2
0
        public void _3_1_ThreeStack_withValidOperations_ShouldPopSuccessfully()
        {
            ThreeStackFixedSize threeStack = new ThreeStackFixedSize(2);

            threeStack.Push(1, 10);
            threeStack.Push(1, 20);
            threeStack.Push(2, 30);
            threeStack.Push(2, 40);
            threeStack.Push(3, 50);
            threeStack.Push(3, 60);

            Assert.AreEqual(20, threeStack.Pop(1));
            Assert.AreEqual(10, threeStack.Pop(1));
            Assert.AreEqual(40, threeStack.Pop(2));
            Assert.AreEqual(30, threeStack.Pop(2));
            Assert.AreEqual(60, threeStack.Pop(3));
            Assert.AreEqual(50, threeStack.Pop(3));
        }