public void Push_Should_AddItem_When_ThereIsOnlyOneSpaceLeft()
        {
            var obj = new CircularStack <int>(2);

            obj.Push(1);
            obj.Push(2);

            Assert.AreEqual(2, obj.Count);
            obj.ShouldContainElementsInOrder(2, 1);
        }
        public void Push_Should_AddItem()
        {
            var arr = new List <string> {
                "a", "b"
            };
            var obj = new CircularStack <string>(arr, 4);

            obj.Push("c");

            Assert.AreEqual(3, obj.Count);
            obj.ShouldContainElementsInOrder("c", "b", "a");
        }
        public void Push_Should_Work_When_StackIsInitializedFromCollection()
        {
            var arr = new List <string> {
                "a", "b", "c"
            };
            var obj = new CircularStack <string>(arr, 5);

            var expected = "d";

            obj.Push(expected);
            obj.ShouldContainElementsInOrder("d", "c", "b", "a");
        }
        public void Pop_Should_RemoveItem()
        {
            var arr = new List <string> {
                "a", "b"
            };
            var obj = new CircularStack <string>(arr);

            obj.Pop();

            Assert.AreEqual(1, obj.Count);
            obj.ShouldContainElementsInOrder("a");
        }
        public void Push_Should_DropLastItem_When_StackIsFull()
        {
            var expected = "b";
            var arr      = new List <string> {
                "a", expected
            };
            var obj = new CircularStack <string>(arr);

            obj.Push("c");

            obj.ShouldContainElementsInOrder("c", "b");
        }
        public void Pop_Should_WorkAfterPush()
        {
            var expected = "k";
            var arr      = new List <string> {
                "a", "b", "d"
            };
            var obj = new CircularStack <string>(arr);

            obj.Push(expected);
            var actual = obj.Pop();

            Assert.AreSame(expected, actual);
            obj.ShouldContainElementsInOrder("d", "b");
        }
        public void Push_Should_WorkAfterPop()
        {
            var expected = "c";
            var arr      = new List <string> {
                "a", "b", "d"
            };
            var obj = new CircularStack <string>(arr);

            obj.Pop();
            obj.Push(expected);

            Assert.AreSame(expected, obj.Peek());
            obj.ShouldContainElementsInOrder("c", "b", "a");
        }