public void TestProcessInputCommandRestart() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); TopScores scores = new TopScores(); MockLabyrinthBoard testBoard = new MockLabyrinthBoard(closedLabyrinth); MockingUserInterface userInterface = new MockingUserInterface(); userInterface.FakeInput = "restart"; testEngine = new Engine(testBoard, scores, userInterface); testEngine.Start(); string expected = testBoard.ToString(); string output = testEngine.Labyrinth.ToString(); Assert.AreNotEqual<string>(expected, output); } }
public void TestStartMethodForCorrectOutput() { using (StringWriter sw = new StringWriter()) { Console.SetOut(sw); TopScores scores = new TopScores(); MockLabyrinthBoard testBoard = new MockLabyrinthBoard(mockLabyrinth); MockingUserInterface userInterface = new MockingUserInterface(); userInterface.FakeInput = "exit"; testEngine = new Engine(testBoard,scores,userInterface); testEngine.Start(); string welcomeString = "Welcome to “Labirinth” game. Your goal is to escape. \nUse 'top' to view the top scoreboard, \n'restart' to start a new game \nand 'exit' to quit the game.\n"; string boardString = testBoard.ToString(); string enterMoveString = "\nEnter your move (L=left, R=right, U=up, D=down):"; StringBuilder startMethodOutput = new StringBuilder(); startMethodOutput.Append(welcomeString); startMethodOutput.Append(Environment.NewLine); startMethodOutput.Append(boardString); startMethodOutput.Append(enterMoveString); startMethodOutput.Append("Good Bye!"); startMethodOutput.Append(Environment.NewLine); string expected = startMethodOutput.ToString(); string output = sw.ToString(); Assert.AreEqual<string>(expected, output); } }