예제 #1
0
        public void TestingPushAndPopTogether()
        {
            var stack = new StackKata <int>();

            stack.Push(5);
            Assert.That(stack.Pop(), Is.EqualTo(5));
        }
예제 #2
0
        public void TestingPushOneElemet()
        {
            var stack = new StackKata <int>();

            stack.Push(5);
            Assert.That(stack.Count, Is.EqualTo(1));
        }
예제 #3
0
        public void PopShouldRemoveLastPush()
        {
            var stack = new StackKata <int>();

            stack.Push(7);
            stack.Push(9);
            stack.Push(1);
            Assert.That(stack.Pop(), Is.EqualTo(1));
            Assert.That(stack.Count, Is.EqualTo(2));
        }
예제 #4
0
        public void TestPopOnly()
        {
            var expectedList = new List <int>();

            expectedList.Add(5);
            expectedList.Add(7);
            expectedList.Add(9);
            expectedList.Add(1);

            var stack = new StackKata <int>(expectedList);

            Assert.That(stack.Pop(), Is.EqualTo(1));
            Assert.That(stack.Pop(), Is.EqualTo(9));
            Assert.That(stack.Pop(), Is.EqualTo(7));
            Assert.That(stack.Pop(), Is.EqualTo(5));
        }
예제 #5
0
        public void TestPushOnly()
        {
            var expectedList = new List <int>();

            expectedList.Add(5);
            expectedList.Add(7);
            expectedList.Add(9);
            expectedList.Add(1);

            var stack = new StackKata <int>();

            stack.Push(5);
            stack.Push(7);
            stack.Push(9);
            stack.Push(1);


            Assert.That(stack.GetAsList(), Is.EqualTo(expectedList));
        }
예제 #6
0
        public void PoppingAnEmptyStackShouldThrowInvalidOperationException()
        {
            var stack = new StackKata <int>();

            Assert.That(() => stack.Pop(), Throws.InvalidOperationException);
        }