예제 #1
0
        public void Should_GetCorrectShotResult_WithSingleShot(string shotKey, ShotResultType shotResultType, ShipType?shipType = null)
        {
            // Arrange
            var expectedGameField = ShotKeyInterpreter.GetGameField(shotKey, _gameBoard.GridSize);

            // Act
            var shotResult = _gameBoard.ShootAt(shotKey);

            // Assert
            shotResult.Should().NotBeNull();
            shotResult.ShotResultType.Should().Be(shotResultType);
            shotResult.ShipType.Should().Be(shipType);
            shotResult.GameField.Should().Be(expectedGameField);
        }
예제 #2
0
        public static string EnumTypeToString(ShotResultType type)
        {
            switch (type)
            {
            case ShotResultType.Miss:
                return(ShootResultJsonTypes.Miss);

            case ShotResultType.Damage:
                return(ShootResultJsonTypes.Damage);

            case ShotResultType.Kill:
                return(ShootResultJsonTypes.Kill);
            }

            throw new ArgumentException($"Тип не определён, тип - {type.ToString()}.", nameof(type));
        }
예제 #3
0
 public ShotResult(GameField gameField, ShotResultType shotResultType, ShipType?shipType = null)
 {
     GameField      = gameField;
     ShotResultType = shotResultType;
     ShipType       = shipType;
 }