public async Task GivenShip_Must_Be_Able_To_Place_On_Board_Horizontally() { using (var server = new ServerFixture(databasePort: _databaseFixture.Port)) { var boardId = Guid.NewGuid(); var shipId = Guid.NewGuid(); server .Arrange() .AddBoard(new Board { Id = boardId, RowSize = 10, ColumnSize = 10 }) .AddShip(new Ship { Id = shipId, Size = 3 }); var placeShipRequest = new PlaceShipRequest { RowStartPosition = 1, ColumnStartPosition = 1, PositionStyle = PositionStyle.Horizontal }; var response = await server.Client.PostAsJsonAsync($"boards/{boardId}/ships/{shipId}/place", placeShipRequest); response.StatusCode.Should().Be(HttpStatusCode.NoContent); var shipPositions = await server.Assert().GetShipPositions(); shipPositions.Any(x => x.RowPosition == 1 && x.ColumnPosition == 1).Should().BeTrue(); shipPositions.Any(x => x.RowPosition == 1 && x.ColumnPosition == 2).Should().BeTrue(); shipPositions.Any(x => x.RowPosition == 1 && x.ColumnPosition == 3).Should().BeTrue(); } }
private void SetupAttackTestData(ServerFixture server, Guid boardId, Guid ship1Id, Guid ship2Id) { server .Arrange() .AddBoard(new Board { Id = boardId, RowSize = 10, ColumnSize = 10 }) .AddShip(new Ship { Id = ship1Id, Size = 3 }) .AddShip(new Ship { Id = ship2Id, Size = 5 }) .AddShipPositions(boardId, ship1Id, new List <ShipPosition> { new ShipPosition { RowPosition = 1, ColumnPosition = 1 }, new ShipPosition { RowPosition = 1, ColumnPosition = 2 }, new ShipPosition { RowPosition = 1, ColumnPosition = 3 } }) .AddShipPositions(boardId, ship2Id, new List <ShipPosition> { new ShipPosition { RowPosition = 2, ColumnPosition = 1 }, new ShipPosition { RowPosition = 3, ColumnPosition = 1 }, new ShipPosition { RowPosition = 4, ColumnPosition = 1 }, new ShipPosition { RowPosition = 5, ColumnPosition = 1 }, new ShipPosition { RowPosition = 6, ColumnPosition = 1 } }) .AddAttackPositions(boardId, ship1Id, new List <AttackPosition> { new AttackPosition { RowPosition = 1, ColumnPosition = 1, Status = AttackStatus.Hit }, new AttackPosition { RowPosition = 1, ColumnPosition = 3, Status = AttackStatus.Hit } }); }