public void QuitGameCommandShouldCallNotifier() { var mockedNotifier = new Mock<INotifier>(); IDataState data = new Data(); ICommand quitGameCommand = new QuitGameCommand(mockedNotifier.Object); quitGameCommand.Execute(); mockedNotifier.Verify(m => m.Notify(It.IsAny<string>()), Times.Once); }
/// <summary> /// Creates a command according to the user input /// </summary> /// <param name="command">Command to be created</param> /// <returns>The created command</returns> public ICommand GetCommand(string command) { if (!this.CommandsList.ContainsKey(command)) { ICommand commandExecutor = null; switch (command) { case "help": { commandExecutor = new CheatCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "start": { commandExecutor = new InitializeGameCommand(this.Data, this.Notifier, this.NumberGenerator); break; } case "commands": { commandExecutor = new DisplayCommandsListCommand(this.Notifier); break; } case "top": { commandExecutor = new DisplayScoreboardCommand(this.Scoreboard); break; } case "quit": { commandExecutor = new QuitGameCommand(this.Notifier); break; } case "exit": { commandExecutor = new ExitGameCommand(this.Notifier); break; } case "empty": { commandExecutor = new EmptyCommand(); break; } default: { commandExecutor = this.ProcessGuessAndReturnAppropriateCommand(command); break; } } this.CommandsList.Add(command, commandExecutor); return commandExecutor; } else { return this.CommandsList[command]; } }