public void ReadBoardSizeTest_ValidSize5() { TestConsoleUI testConsole = new TestConsoleUI(); testConsole.Input = "5"; StringBuilder expectedOutput = new StringBuilder(); expectedOutput.Append("Welcome to \"Battle Field game.\" Enter battlefield size: N = "); int boardSize = GameEngine.ReadBoardSize(testConsole); Assert.AreEqual(5, boardSize); Assert.AreEqual(expectedOutput.ToString(), testConsole.Output.ToString()); }
public void PlayGameTest_SuccessfulGamePlayed1Bomb() { TestConsoleUI testConsole = new TestConsoleUI(); testConsole.Input = "1 1"; StringBuilder expectedOutput = new StringBuilder(); Board board = new Board(3); var initialBoard = new string[3,3] { {"-", "-", "-"}, {"-", "1", "-"}, {"-", "-", "-"} }; var expectedBoard = new string[3,3] { {"X", "-", "X"}, {"-", "X", "-"}, {"X", "-", "X"} }; SetBoard(board, initialBoard); expectedOutput.AppendLine("Please enter coordinates: "); expectedOutput.AppendLine(" 0 1 2"); expectedOutput.AppendLine(" -----"); expectedOutput.AppendLine("0|X - X "); expectedOutput.AppendLine("1|- X - "); expectedOutput.AppendLine("2|X - X "); expectedOutput.AppendLine(); expectedOutput.AppendLine("Game over. Detonated mines: 1"); GameEngine.PlayGame(board, testConsole); Assert.IsTrue(EqualBoards(expectedBoard, board.GameBoard)); Assert.AreEqual(expectedOutput.ToString(), testConsole.Output.ToString()); }
public void ReadBoardSizeTest_TwiceInvalidSize0ThenValid5() { TestConsoleUI testConsole = new TestConsoleUI(); testConsole.Input = "0\n0\n5"; StringBuilder expectedOutput = new StringBuilder(); expectedOutput.Append("Welcome to \"Battle Field game.\" Enter battlefield size: N = "); expectedOutput.AppendLine("Enter a number between 1 and 10!"); expectedOutput.AppendLine("Enter a number between 1 and 10!"); int boardSize = GameEngine.ReadBoardSize(testConsole); Assert.AreEqual(5, boardSize); Assert.AreEqual(expectedOutput.ToString(), testConsole.Output.ToString()); }