public void TestExecuteCommand_WithTopCommand() { Engine game = new Engine(); GameField gameField = new GameField(10, 10); char[,] fieldWithQuestionMarks = gameField.Create(); char[,] fieldWithBombs = gameField.PlaceBombs(); int maxScore = (gameField.FieldCols * gameField.FieldCols) - (gameField.FieldCols + gameField.FieldCols); string inputCommand = "top"; List<Player> topPlayers = new List<Player>(); StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendLine("Points:"); expectedOutput.AppendLine("Empty score board."); using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); game.ExecuteCommand(inputCommand, gameField, fieldWithQuestionMarks, fieldWithBombs, maxScore); Assert.AreEqual<string>(expectedOutput.ToString(), sw.ToString()); } }
public void TestExecuteCommand_WithRestartCommand() { Engine game = new Engine(); GameField gameField = new GameField(2, 2); char[,] fieldWithQuestionMarks = gameField.Create(); char[,] fieldWithBombs = gameField.PlaceBombs(); int maxScore = (gameField.FieldCols * gameField.FieldCols) - (gameField.FieldCols + gameField.FieldCols); string inputCommand = "restart"; StringBuilder expectedOutput = new StringBuilder(); expectedOutput.AppendFormat(" 0 1 2 3 4 5 6 7 8 9{0}", Environment.NewLine); expectedOutput.AppendFormat(" ---------------------{0}", Environment.NewLine); expectedOutput.AppendFormat("0 | ? ? |{0}", Environment.NewLine); expectedOutput.AppendFormat("1 | ? ? |{0}", Environment.NewLine); expectedOutput.AppendFormat(" ---------------------{0}", Environment.NewLine); using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); game.ExecuteCommand(inputCommand, gameField, fieldWithQuestionMarks, fieldWithBombs, maxScore); Assert.AreEqual<string>(expectedOutput.ToString(), sw.ToString()); } }