Esempio n. 1
0
        public void TestCount()
        {
            ArrayStack <int> stack = new ArrayStack <int>();

            Assert.AreEqual(0, stack.Count);
            stack.Push(1);
            stack.Push(2);
            stack.Push(3);
            Assert.AreEqual(3, stack.Count);
            stack.Pop();
            Assert.AreEqual(2, stack.Count);
            stack.Pop();
            stack.Pop();
            Assert.AreEqual(0, stack.Count);
        }
Esempio n. 2
0
        public void TestPopEmpty()
        {
            ArrayStack <int> stack = new ArrayStack <int>();

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

            Assert.AreEqual(3, stack.Pop());
            Assert.AreEqual(2, stack.Pop());
            Assert.AreEqual(1, stack.Pop());

            //Op een lege stack kunnen we geen pop doen
            //we controleren op een "fout" (Exception)
            Assert.Catch(() => stack.Pop());
        }