Example #1
0
        // [Fact]
        public void CanPeek()
        {
            StackClass <int> stack = new StackClass <int>();
            Node <int>       node  = new Node <int>();

            node.Value = 5;
            stack.Push(node.Value);
            Node <int> node2 = new Node <int>();

            node.Value = 15;
            stack.Push(node.Value);
            var output = stack.Peek();
        }
Example #2
0
        public static void RunPushMethod()
        {
            StackClass <int> stack = new StackClass <int>();

            Console.WriteLine("Choose a number to push to stack");
            int input1 = Convert.ToInt32(Console.ReadLine());



            stack.Push(input1);

            Console.WriteLine(stack.Peek());
        }
Example #3
0
        public void CanEmptyStack()
        {
            StackClass <int> stack = new StackClass <int>();
            Node <int>       node  = new Node <int>();

            node.Value = 5;
            stack.Push(node.Value);
            Node <int> node2 = new Node <int>();

            node.Value = 15;
            stack.Push(node.Value);
            Node <int> node3 = new Node <int>();

            node.Value = 22;
            stack.Push(node.Value);
            while (node.Next != null)
            {
                stack.Pop();
            }
            stack.Pop();
            var result = stack.Peek();

            Assert.Null(result);
        }