public void AttackTest() { // Arrange System.Drawing.Point coordinate = new System.Drawing.Point(1, 1); string board = "A"; var expected = true; // Act var output = subject.Attack(coordinate, board); // Assert output.ShouldBe(expected); subject.BoardAState.Panels.Where(panel => panel.OccupationType == Application.Board.Models.OccupationType.Hit).Count().ShouldBe(0); subject.BoardAState.Panels.Where(panel => panel.OccupationType == Application.Board.Models.OccupationType.Miss).Count().ShouldBe(1); }
public void MissTestForOneShipInTheBoard(int posX1, int posY1, int posX2, int posY2, int attackX, int attackY) { _boardService = new BoardService(new Board(_boardWidth, _boardHeight)); _boardService.SetupBoard(); Position start = new Position(posX1, posY1); Position end = new Position(posX2, posY2); Ship ship = new Ship(start, end); _boardService.AddShip(ship); bool isHit = _boardService.Attack(new Position(attackX, attackY)); Assert.AreEqual(isHit, false); }
public void SinkTestForOneShipOnTheBoard(int shipStartPosX, int shipStartPosY, int shipEndPosX, int shipEndPosY) { _boardService = new BoardService(new Board(_boardWidth, _boardHeight)); _boardService.SetupBoard(); Ship ship = new Ship(new Position(shipStartPosX, shipStartPosY), new Position(shipEndPosX, shipEndPosY)); _boardService.AddShip(ship); foreach (Position position in _attackPositions) { _boardService.Attack(position); } Assert.AreEqual(_boardService.AllShipsSunk, true); }