예제 #1
0
        public void ABattleShipCannotBeAddedTest(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));

            bool added = _boardService.AddShip(ship);

            Assert.AreEqual(added, false);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }