public void ExecuteACommandUndoExecuteACommandThenRedoDoesNotCallApplyOnSecondCommand() { var commandStack = new CommandStack(); var mockCommand1 = new Mock<ICommand>(); var mockCommand2 = new Mock<ICommand>(); commandStack.Execute(mockCommand1.Object); commandStack.Undo(); commandStack.Execute(mockCommand2.Object); commandStack.Redo(); mockCommand1.Verify(command => command.Apply(), Times.Exactly(1)); mockCommand1.Verify(command => command.Revert(), Times.Exactly(1)); mockCommand2.Verify(command => command.Apply(), Times.Exactly(1)); mockCommand2.Verify(command => command.Revert(), Times.Exactly(0)); }
public void RedoCallsApplyOnTheLastCommandUndone() { var commandStack = new CommandStack(); var mockCommand1 = new Mock<ICommand>(); var mockCommand2 = new Mock<ICommand>(); commandStack.Execute(mockCommand1.Object); commandStack.Execute(mockCommand2.Object); commandStack.Undo(); commandStack.Redo(); mockCommand1.Verify(command => command.Apply(), Times.Exactly(1)); mockCommand1.Verify(command => command.Revert(), Times.Exactly(0)); mockCommand2.Verify(command => command.Apply(), Times.Exactly(2)); mockCommand2.Verify(command => command.Revert(), Times.Exactly(1)); }