public void CountShouldCountTheNumberOfAddedItems(IStack stack)
        {
            stack.Push(34);
            stack.Push(8);
            stack.Pop();

            Assert.AreEqual(1, stack.Count());
        }
 public void PushShouldWorkWhenWeAddedHundredAndOneElements(IStack stack)
 {
     for (int i = 0; i <= 100; i++)
     {
         stack.Push(1);
     }
     Assert.AreEqual(101, stack.Count());
 }
        public void PushAndPopShouldWorkCorrect(IStack stack)
        {
            stack.Push(9);
            stack.Push(8);
            stack.Pop();
            stack.Pop();

            Assert.Throws <System.InvalidOperationException>(() => stack.Pop());
            Assert.AreEqual(0, stack.Count());
        }
Ejemplo n.º 4
0
        private static void RunIStackTest(IStack <int> stack)
        {
            int size = 32;

            Console.Write("Push: ");
            for (int i = 1; i <= size; i++)
            {
                stack.Push(i);
                Console.Write($"{i}, ");
            }
            Console.WriteLine();

            Console.WriteLine($"Peek: {stack.Peek()}, Count: {stack.Count()}");

            Console.Write("Pop: ");
            for (int i = 1; i <= size; i++)
            {
                Console.Write($"{stack.Pop()}, ");
            }
            Console.WriteLine('\n');
        }