Esempio n. 1
0
        public void PopTest()
        {
            var c1 = new TestCommand("1");
            var c2 = new TestCommand("2");
            var c3 = new TestCommand("3");
            var ch = new CommandsHistory();

            ch.Push(c1);
            ch.Push(c2);
            ch.Push(c3);

            Assert.Equal(c3, ch.Pop());
            Assert.Equal(c2, ch.Pop());
            Assert.Equal(c1, ch.Pop());
        }
Esempio n. 2
0
        public void CantMoveForward()
        {
            var c1 = new TestCommand("1");
            var c2 = new TestCommand("2");
            var c3 = new TestCommand("3");
            var ch = new CommandsHistory();

            ch.Push(c1);
            ch.Push(c2);
            ch.Push(c3);

            var moved = ch.TryMoveForward(out var actual);

            Assert.False(moved);
            Assert.Equal(null, actual);
        }
Esempio n. 3
0
        public void ClearingUnusedItems()
        {
            var c1 = new TestCommand("1");
            var c2 = new TestCommand("2");
            var c3 = new TestCommand("3");
            var c4 = new TestCommand("4");
            var ch = new CommandsHistory();

            ch.Push(c1);
            ch.Push(c2);
            ch.Push(c3);
            ch.Push(c4);

            ch.Pop();
            ch.Pop();
            ch.Pop();
            ch.Push(c4);

            Assert.Equal(c4, ch.Pop());
        }