public void StackMin_ShouldRemoveMinValues_AfterPoppingThemOut()
        {
            stack.Push(3);
            stack.Push(2);
            stack.Push(1);
            Assert.AreEqual(1, stack.Min());

            stack.Pop();
            Assert.AreEqual(2, stack.Min());

            stack.Pop();
            Assert.AreEqual(3, stack.Min());
        }
Beispiel #2
0
        public void Pop_An_Element_In_A_Stack_With_No_Element()
        {
            var stack = new StackMin();

            var item = stack.Pop();

            Assert.Equal(0, item);
            Assert.Equal(0, stack.Length);
            Assert.Null(stack.Top);
            Assert.Null(stack.Bottom);
            Assert.Equal(int.MaxValue, stack.Min());
        }
Beispiel #3
0
        public void Pop_Two_Elements_In_A_Stack_With_Three_Elements()
        {
            var stack = new StackMin();

            stack.Push(30);
            stack.Push(20);
            stack.Push(10);

            Assert.Equal(10, stack.Min());
            var item1 = stack.Pop();

            Assert.Equal(20, stack.Min());
            var item2 = stack.Pop();

            Assert.Equal(10, item1);
            Assert.Equal(20, item2);
            Assert.Equal(1, stack.Length);
            Assert.Equal(30, stack.Top.Value);
            Assert.Equal(30, stack.Bottom.Value);
            Assert.Equal(30, stack.Min());
        }