예제 #1
0
        public void TestClear_EmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();

            stack.Clear();

            Assert.AreEqual(0, stack.Count);
            Assert.AreEqual(string.Empty, stack.ToString());
        }
예제 #2
0
        public void TestToString_NonEmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();
            int stackCount          = 10;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            Assert.AreEqual("9876543210", stack.ToString());
        }
예제 #3
0
        public void TestPush_TenItems()
        {
            StaticStack <int> stack = new StaticStack <int>();

            int stackCount = 10;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            Assert.AreEqual(stackCount, stack.Count);
            Assert.AreEqual("9876543210", stack.ToString());
        }
예제 #4
0
        public void TestClear_NonEmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();
            int stackCount          = 5;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            stack.Clear();

            Assert.AreEqual(0, stack.Count);
            Assert.AreEqual(string.Empty, stack.ToString());
        }
예제 #5
0
        public void TestClone_EmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();
            StaticStack <int> clone = (StaticStack <int>)stack.Clone();

            int count = 5;

            for (int i = 0; i < count; i++)
            {
                stack.Push(i);
            }

            Assert.AreEqual(5, stack.Count);
            Assert.AreEqual(0, clone.Count);
            Assert.AreEqual(string.Empty, clone.ToString());
        }
예제 #6
0
        public void TestPop_OneItem()
        {
            StaticStack <int> stack = new StaticStack <int>();

            int stackCount = 5;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            int popped = stack.Pop();

            Assert.AreEqual(4, popped);
            Assert.AreEqual(4, stack.Count);
            Assert.AreEqual("3210", stack.ToString());
        }
예제 #7
0
        public void TestPop_MultipleItems()
        {
            StaticStack <int> stack = new StaticStack <int>();

            int stackCount = 10;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            for (int i = 0; i < 5; i++)
            {
                int popped = stack.Pop();
                Assert.AreEqual(9 - i, popped);
            }

            Assert.AreEqual(5, stack.Count);
            Assert.AreEqual("43210", stack.ToString());
        }
예제 #8
0
        public void TestClone_NonEmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();

            int stackCount = 5;

            for (int i = 0; i < stackCount; i++)
            {
                stack.Push(i);
            }

            StaticStack <int> clone = (StaticStack <int>)stack.Clone();

            for (int i = 0; i < stackCount; i++)
            {
                stack.Pop();
            }

            Assert.AreEqual(0, stack.Count);
            Assert.AreEqual(5, clone.Count);
            Assert.AreEqual("43210", clone.ToString());
        }
예제 #9
0
        public void TestToString_EmptyStack()
        {
            StaticStack <int> stack = new StaticStack <int>();

            Assert.AreEqual(string.Empty, stack.ToString());
        }