public void ShouldThrowWhenInvalidMatrixTypeIsPassed() { var startCommand = new StartCommand(MinesweeperEngine.Instance, this.matrix, this.player, new MatrixDirector(), new MediumMatrixBuilder(), this.printer); ICommandInfo command = new CommandInfo(string.Empty, new List<string>() { "invalid type" }); Assert.Throws(typeof(ArgumentOutOfRangeException), () => startCommand.Execute(command)); }
public void ShouldBeAbleToCreateMatrixOfDifferentTypes(string matrixType) { var startCommand = new StartCommand(MinesweeperEngine.Instance, this.matrix, this.player, new MatrixDirector(), new MediumMatrixBuilder(), this.printer); ICommandInfo commandInfo = new CommandInfo(string.Empty, new List<string>() { matrixType }); Assert.DoesNotThrow(() => startCommand.Execute(commandInfo)); }
/// <summary> /// Method which process input commands /// </summary> /// <param name="command">inut command</param> public void ExecuteCommand(string command) { CommandInfo commandInfo = (CommandInfo)this.commandParser.Parse(command); Command currentCommand = null; switch (commandInfo.Name) { case "start": currentCommand = new StartCommand(this, this.matrix, this.player, this.director, this.builder, this.printer); break; case "turn": currentCommand = new TurnCommand(this, this.matrix, this.player, this.printer); break; case "menu": MainMenu.PrintMenu(this); break; case "exit": currentCommand = new ExitCommand(this.matrix, this.player, this.printer); break; case "save": currentCommand = new SaveCommand(this.matrix, this.player, this.printer); break; case "load": currentCommand = new LoadCommand(this.matrix, this.player, this.printer); break; case "mode": currentCommand = new ChangeModeCommand(this, this.matrix, this.player, this.printer); break; case "highscore": currentCommand = new HighScoreCommand(this, this.matrix, this.player, this.printer); break; default: currentCommand = new InvalidCommand(this.matrix, this.player, this.printer); currentCommand.Execute(commandInfo); this.Start(); return; } currentCommand.Execute(commandInfo); this.printer.PrintMatrix(this.matrix, this.player); this.Start(); }