public void Should_ThrowValidationException_WhenInputIsInvalid(string input)
        {
            // Act
            var exception = Assert.Throws <ArgumentException>(() => ShotKeyInterpreter.GetGameField(input, gridSize: 10));

            // Assert
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentException>();
        }
        public void Should_GetCorrectGameField_FromShotKey(string shotKey, int expectedX, int expectedY)
        {
            // Act
            var field = ShotKeyInterpreter.GetGameField(shotKey, gridSize: 10);

            // Assert
            field.Should().NotBeNull();
            field.X.Should().Be(expectedX);
            field.Y.Should().Be(expectedY);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public ShotResult ShootAt(string shotKey)
        {
            var gameField = ShotKeyInterpreter.GetGameField(shotKey, GridSize);

            return(ShootAt(gameField));
        }