public void ToShortString() { var board = new BoardContent(SquareContent.Water); board[0] = SquareContent.Ship; board[1] = SquareContent.Unknown; board[2] = SquareContent.SunkenShip; board[3] = SquareContent.HitShip; var result = board.ToShortString(); Assert.Equal("S XH", result[0..4]);
public ActionResult <BoardIndex[]> GetShots([FromBody] ShotRequest[] shotRequests) { // Create a helper variable that will receive our calculated // shots for each shot request. var shots = new BoardIndex[shotRequests.Length]; Parallel.For(0, shotRequests.Length, index => { var board = new BoardContent(shotRequests[index].Board.Select(d => (byte)BoardContentJsonConverter.CharToSquareContent(d))); #if DEBUG Console.WriteLine(board); Console.WriteLine(board.ToShortString()); #endif shots[index] = BattleshipHelper.GetNextShot(board); #if DEBUG Console.WriteLine($"Next shot:{(string)shots[index]}"); ////Thread.Sleep(500); #endif }); return(shots); }