/// <summary> /// Gets the wanted command based on the input. /// </summary> /// <param name="command">The concrete command name.</param> /// <returns>An object which implements the ICommand interface.</returns> public ICommand GetCommand(string command) { command = command.ToLower(); if (this.commandDictionary.ContainsKey(command)) { return this.commandDictionary[command]; } else { ICommand newCommand; switch (command) { case "pop": newCommand = new PopBalloonCommand(); break; case "exit": newCommand = new ExitCommand(); break; case "restart": newCommand = new RestartCommand(); break; case "top": newCommand = new ShowTopScoreCommand(); break; case "undo": newCommand = new UndoCommand(); break; case "invalidinput": newCommand = new InvalidInputCommand(); break; default: throw new ArgumentException("Invalid command " + command.ToLower()); } this.commandDictionary.Add(command, newCommand); return newCommand; } }
public RestartCommandTests() { this.context = new MockIContext().MockContext.Object; this.command = new RestartCommand(); }