public void Undo_PerformsUndo() { var commandExecutionManager = new CommandExecutionManager(); var commandMock = new Mock <ICommand>(); commandExecutionManager.ExecuteCommand(commandMock.Object); commandExecutionManager.Undo(); commandMock.Verify(c => c.Undo(), Times.Once()); }
public void Redo_PerformsRedo() { var commandExecutionManager = new CommandExecutionManager(); var commandMock = new Mock <ICommand>(); commandExecutionManager.ExecuteCommand(commandMock.Object); commandExecutionManager.Undo(); commandExecutionManager.Redo(); commandMock.Verify(c => c.Execute(), Times.Exactly(2)); }
public void ExecuteCommand_ClearsUndoHistory() { var commandExecutionManager = new CommandExecutionManager(); var commandMock = new Mock <ICommand>(); commandExecutionManager.ExecuteCommand(commandMock.Object); commandExecutionManager.Undo(); commandExecutionManager.ExecuteCommand(commandMock.Object); Assert.Throws <InvalidOperationException>(() => commandExecutionManager.Redo()); }
public void Undo_NothingToUndo_InvalidOperationException() { var commandExecutionManager = new CommandExecutionManager(); Assert.Throws <InvalidOperationException>(() => commandExecutionManager.Undo()); }