Esempio n. 1
0
        public void ReceiveShot_AllShipsSunk_ReturnsWin()
        {
            var            board           = GetBoard();
            var            shipCoordinates = board.Ships.SelectMany(ship => ship.Position);
            ShipShotResult result          = null;

            foreach (var coordinates in shipCoordinates)
            {
                result = board.ReceiveShot(coordinates);
            }

            result.Result.Should().Be(ShotResult.Won);
            result.MaybeShip.HasValue.Should().BeTrue();
            result.MaybeShip.Value.Should().NotBeNull();
        }
Esempio n. 2
0
        public void ReceiveShot_AllPositionsOfSingleShipHit_ReturnsSunk()
        {
            var            board           = GetBoard();
            var            shipCoordinates = board.Ships[0].Position;
            ShipShotResult result          = null;

            foreach (var coordinates in shipCoordinates)
            {
                result = board.ReceiveShot(coordinates);
            }

            result.Result.Should().Be(ShotResult.Sunk);
            result.MaybeShip.HasValue.Should().BeTrue();
            result.MaybeShip.Value.Should().NotBeNull();
        }