public void ItShould_Handle_Null() { var command = new ClearHistoryCommand(null); command.Execute(); _documentHistoryCommandMock.Verify(v => v.Clear(), Times.Never); }
public void ItShould_Call_Clear() { var command = new ClearHistoryCommand(_documentHistoryCommandMock.Object); command.Execute(); _documentHistoryCommandMock.Verify(v => v.Clear(), Times.Once); }
private void ProcessCommands(string commands) { string commandType = String.Join(string.Empty, commands.Split()); ICommand command = null; string commandResult = String.Empty; switch (commandType) { case "register": case "registeruser": command = new RegisterCommand(); break; case "login": case "log": command = new LoginCommand(); break; case "logout": command = new LogOutCommand(); break; case "addnotebook": command = new AddNotebookCommand(); break; case "addnote": if (loggedUser.Notebooks.Count == 0) { throw new ArgumentException(Messages.MustCreateANotebook()); } command = new AddNoteCommand(); break; case "switchnotebook": command = new SwitchNotebookCommand(); break; case "addtask": command = new AddTaskCommand(); break; case "addlongtermtask": command = new AddLongTermTaskCommand(); break; case "addsubtask": command = new AddSubtaskCommand(); break; case "addremindertotask": command = new AddReminderToTaskCommand(); break; case "addnotetofavourites": command = new AddNoteToFavouritesCommand(); break; case "addnotebooktofavourites": command = new AddNotebookToFavouritesCommand(); break; case "listall": command = new ListCommand(); break; case "listtask": command = new ListTask(); break; case "listnotebook": command = new ListNotebookCommand(); break; case "listnote": command = new ListNoteCommand(); break; case "listlongtermtask": command = new ListLongTermTaskCommand(); break; case "listsubtask": command = new ListSubTaskCommand(); break; case "switchlongtertask": command = new SwitchLongTermTaskCommand(); break; case "deletetask": command = new DeleteTaskCommand(); break; case "deletesubtask": command = new DeleteSubTaskCommand(); break; case "clearhistory": command = new ClearHistoryCommand(); break; default: break; } command.TakeInput(); commandResult = command.Execute(); Writer.WriteLine(commandResult); }