public void ValidatesUnderflowCondition()
        {
            IStack <int> intStack = new SampleStack <int>();
            var          ex       = Assert.Throws <InvalidOperationException>(() => intStack.Pop());

            Assert.That(ex.Message, Is.EqualTo("Underflow!"));
        }
        public void ValidatesPoppedObjEqualsPushedObj(int value)
        {
            IStack <int> intStack = new SampleStack <int>();

            intStack.Push(value);
            Assert.AreEqual(value, intStack.Pop());
        }
        public void ValidatesizeAfterPop()
        {
            IStack <int> intStack = new SampleStack <int>();

            intStack.Push(1);
            intStack.Pop();
            Assert.True(intStack.IsEmpty());
            Assert.AreEqual(0, intStack.Size());
        }
Example #4
0
        public void GivenStackWithLengthFive_Pop_TwoItems_LengthOfStackShouldBeThree()
        {
            //Arrange
            var size        = 5;
            var sampleStack = new SampleStack(size);

            sampleStack.Push(1);
            sampleStack.Push(2);
            sampleStack.Push(3);
            sampleStack.Push(4);
            sampleStack.Push(5);

            //Act
            sampleStack.Pop();
            sampleStack.Pop();

            //Assert
            Assert.AreEqual(3, sampleStack.Count);
        }
        public void ValidatesPopElement()
        {
            IStack <int> intStack = new SampleStack <int>();

            intStack.Push(1);
            intStack.Push(3);
            intStack.Push(2);
            intStack.Pop();
            Assert.AreEqual(2, intStack.Size());
        }
Example #6
0
        public void GivenStackWithLengthZero_Pop_ShouldThrowIndexOutOfRangeException()
        {
            //Arrange
            var size        = 0;
            var sampleStack = new SampleStack(size);

            //Act
            Action action = () => sampleStack.Pop();

            //Assert
            Assert.ThrowsException <IndexOutOfRangeException>(action);
        }
        public void ValidatesRemovedObjectsBackwards()
        {
            IStack <int> intStack = new SampleStack <int>();

            int[] list = { 1, 3, 5 };
            for (int i = 0; i < list.Length; ++i)
            {
                intStack.Push(list[i]);
            }
            for (int i = list.Length - 1; i >= 0; --i)
            {
                Assert.AreEqual(list[i], intStack.Pop());
            }
        }