public void TestDisplayBoardDisplaysAnEmptyBoard() { // Given var sut = new View(); var presenterSpy = new PresenterSpy(); sut.presenter = presenterSpy; var model = new Model(); var originalConsoleOut = Console.Out; // preserve the original stream var writer = new StringWriter(); Console.SetOut(writer); // When sut.DisplayBoard(model); // Then using (writer) { Console.WriteLine("some stuff"); // or make your DLL calls :) writer.Flush(); // when you're done, make sure everything is written out var printedString = writer.GetStringBuilder().ToString(); Console.SetOut(originalConsoleOut); // restore Console.Out Assert.IsNotNull(printedString, "Displaying board should cause " + "something to be printed"); } }
public void TestDisplayIllegalMovedDisplaysAnErrorMessage() { // Given var sut = new View(); var presenterSpy = new PresenterSpy(); sut.presenter = presenterSpy; var originalConsoleOut = Console.Out; // preserve the original stream var writer = new StringWriter(); Console.SetOut(writer); // When sut.DisplayIllegalMove(); // Then using (writer) { writer.Flush(); // when you're done, make sure everything is written out var printedString = writer.GetStringBuilder().ToString(); Console.SetOut(originalConsoleOut); // restore Console.Out Assert.IsNotNull(printedString, "Displaying an illegal should " + "cause something to be printed"); } }
public void TestDisplayGameWonDisplaysAnCongratulationsMessage() { // Given var sut = new View(); var presenterSpy = new PresenterSpy(); sut.presenter = presenterSpy; var winnerPlayerId = 1; var originalConsoleOut = Console.Out; // preserve the original stream var writer = new StringWriter(); Console.SetOut(writer); // When sut.DisplayGameOverAndWinner(winnerPlayerId); // Then using (writer) { writer.Flush(); // when you're done, make sure everything is written out var printedString = writer.GetStringBuilder().ToString(); Console.SetOut(originalConsoleOut); // restore Console.Out Assert.IsNotNull(printedString, "Displaying game won should cause " + "something to be printed"); } }