public void ReturnTwoAdjacentMinesOnASizeTwoGridAfterAPlayerMove() { //Arrange var newGameGrid = GridFactory.NewGameGrid(2); var updateMineStatus = new MineUpdater(); var mineStub = new StubForTwoMineLocations(); var userInputMove = new PlayerMove(1, 1); //Act updateMineStatus.UpdateCellWithMineStatus(mineStub.MineLocations(newGameGrid.Size), newGameGrid); var result = updateMineStatus.CalculateAdjacentMineTotal(newGameGrid, userInputMove); //Assert Assert.Equal(2, result); }
public void DisplayBoardWithGeneratedMinesCorrectly() { //Arrange var gridSize = 2; var newGrid = GridFactory.NewGameGrid(gridSize); var gameDisplay = GridFactory.NewDisplayGrid(); var mineLogic = MineFactory.NewMineChecker(); var mineLocations = new StubForTwoMineLocations(); mineLogic.UpdateCellWithMineStatus(mineLocations.MineLocations(gridSize), newGrid); //Act var result = gameDisplay.GenerateGameDisplay(newGrid); //Assert Assert.Equal(". + \n+ . \n", result); }
public void ShowTheCorrectGameWinningMessageWhenAPlayerCompletesAGridWithoutHittingAMine() { //Arrange var gridSize = 2; var newMessageDisplay = Factory.NewMessageDisplay(); var gameGrid = GridFactory.NewGameGrid(gridSize); var gameCellUpdater = Factory.NewCellUpdater(); var mineUpdater = MineFactory.NewMineChecker(); var mineStub = new StubForTwoMineLocations(); var userMove = new PlayerMove(0, 1); var expected = $"* 2 {Environment.NewLine}* 2 {Environment.NewLine}Congrats!{Environment.NewLine}You have won!"; //Act mineUpdater.UpdateCellWithMineStatus(mineStub.MineLocations(gridSize), gameGrid); gameCellUpdater.UpdateAdjacentMineTotalAtGameStart(gameGrid); var result = newMessageDisplay.EndGameMessage(gameGrid, userMove); //Assert Assert.Equal(expected, result); }
public void ShowTheCorrectGameLosingMessageWhenAPlayerHitsAMine() { //Arrange var gridSize = 2; var newMessageDisplay = Factory.NewMessageDisplay(); var gameGrid = GridFactory.NewGameGrid(gridSize); var gameCellUpdater = Factory.NewCellUpdater(); var mineUpdater = MineFactory.NewMineChecker(); var mineStub = new StubForTwoMineLocations(); var userMove = new PlayerMove(0, 0); var expected = $"* 2 {Environment.NewLine}* 2 {Environment.NewLine}Sorry, you have lost.{Environment.NewLine}Game over!"; //Act mineUpdater.UpdateCellWithMineStatus(mineStub.MineLocations(gridSize), gameGrid); gameCellUpdater.UpdateAdjacentMineTotalAtGameStart(gameGrid); var result = newMessageDisplay.EndGameMessage(gameGrid, userMove); //Assert Assert.Equal(expected, result); }