public void ToTileValue_WinnerInput_ValidOutput(Winner input, TileValue expectedOutput) { // arrange // act TileValue result = input.ToTileValue(); // assert result.Should().Be(expectedOutput); }
public MoveResult Move(Move m) { try { ValidateNoWinner(); ValidateIsPlayersMove(m.Player); ValidateValidBoardToPlay(m.BoardPosition); SmallBoardInformation board = GetBoard(m.BoardPosition); SmallTileInformation tile = GetTile(board, m.TilePosition); ValidateTileEmpty(tile); tile.Value = m.Player.ToTileValue(); Winner winner = board.Tiles.GetWinner(m.Player); if (winner != Winner.None) { board.Value = winner.ToTileValue(); _winner = _board.GetWinner(m.Player); } // if there is no exception until here the move was valid _moves.Add(m); ChangeCurrentPlayer(); return(new MoveResult { IsValid = true, Move = m, MoveFinishedBoard = winner != Winner.None, MoveFinishedGame = _winner != Winner.None, }); } catch (InvalidMoveException e) { return(new MoveResult { IsValid = false, Move = m, MoveFinishedBoard = false, MoveFinishedGame = false, InvalidReason = e.Message, }); } }