public void TestExecuteCommandClearsRedoStack()
        {
            TestIncrementCommand command = new TestIncrementCommand();
            TestDecrementCommand command2 = new TestDecrementCommand();
            command.Counter = counter;
            command2.Counter = counter;

            commandStack.ExecuteCommand(command);   // counter = 1.
            commandStack.UndoLastCommand();         // counter = 0.
            commandStack.ExecuteCommand(command2);  // counter = -1.

            // Should be a no op, because we have executed since last undoing.
            commandStack.RedoLastUndoneCommand();   // counter = -1.

            Assert.AreEqual(-1, counter.CounterMember, "CommandStack does not clear undo stack after executing a command.");
        }
Пример #2
0
        public void TestExecuteCommandClearsRedoStack()
        {
            TestIncrementCommand command  = new TestIncrementCommand();
            TestDecrementCommand command2 = new TestDecrementCommand();

            command.Counter  = counter;
            command2.Counter = counter;

            commandStack.ExecuteCommand(command);   // counter = 1.
            commandStack.UndoLastCommand();         // counter = 0.
            commandStack.ExecuteCommand(command2);  // counter = -1.

            // Should be a no op, because we have executed since last undoing.
            commandStack.RedoLastUndoneCommand();   // counter = -1.

            Assert.AreEqual(-1, counter.CounterMember, "CommandStack does not clear undo stack after executing a command.");
        }