public void Peek_ShouldNot_RemoveItem()
        {
            var arr = new List <string> {
                "a", "b"
            };
            var obj = new CircularStack <string>(arr);

            obj.Peek();

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

            var actual = obj.Peek();

            Assert.AreSame(expected, actual);
        }
Пример #3
0
        public void PeekPeekBottom01()
        {
            var capacity = 4;
            var cq       = new CircularStack <int>(capacity);

            for (int i = 0; i < 6; i++)
            {
                cq.Push(i);
            }
            Assert.AreEqual(capacity, cq.Count());
            Assert.AreEqual(5, cq.Peek());
            Assert.AreEqual(2, cq.PeekBottom());
        }
Пример #4
0
        public void PushPop01()
        {
            var capacity = 4;
            var cq       = new CircularStack <int>(capacity);

            cq.Push(0);
            cq.Push(1);
            cq.Push(2);
            cq.Push(3);
            cq.Pop();
            cq.Pop();
            Assert.AreEqual(1, cq.Peek());
            Assert.AreEqual(0, cq.PeekBottom());
            cq.Push(4);
            cq.Push(5);
            Assert.AreEqual(5, cq.Peek());
            Assert.AreEqual(0, cq.PeekBottom());
            cq.Push(6);
            cq.Push(7);
            Assert.AreEqual(7, cq.Peek());
            Assert.AreEqual(4, cq.PeekBottom());
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal object Undo()
        {
            var img = HistoryUndo.Count == 1 ? HistoryUndo.Peek() : HistoryUndo.Pop();

            if (img is Image)
            {
                HistoryRedo.Push(imgEditor.Image);
                imgEditor.Image = img;
            }
            Host.OnCommandPropertiesChange(new CommandPropertiesChangeEventArgs(AddinCommand.Undo, HistoryUndo.Count > 1));
            Host.OnCommandPropertiesChange(new CommandPropertiesChangeEventArgs(AddinCommand.Redo, HistoryRedo.Count > 0));
            return(true);
        }
        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");
        }