public void MakeNewMove_RightCoordinates_ExampleWaterAnswer()
        {
            _settingsCheckerMock.Setup(x => x.Check())
            .Returns(ValidationResult.Success);
            var coordinate = new Coordinate('B', "4");

            _coordinateParserMock.Setup(x => x.TryParse("B4", out coordinate))
            .Returns(ValidationResult.Success);
            var grid = new Logic.Grid.Grid();

            grid.Build(10, 8);
            _gridBuilderMock.Setup(x => x.Build())
            .Returns(grid);

            _sut.StartNewGame();

            var result = _sut.MakeNewMove("B4");

            result.Success.Should().BeTrue();
            result.ErrorDescription.Should().BeNull();
            result.Content.Coordinate.Column.Should().Be(1);
            result.Content.Coordinate.Row.Should().Be(3);
            result.Content.Description.Should().Be("Water");

            _settingsCheckerMock.Verify(x => x.Check(), Times.Once);
            _gridBuilderMock.Verify(x => x.Build(), Times.Once);
            _coordinateParserMock.Verify(x => x.TryParse(It.IsAny <string>(), out coordinate), Times.Once);
            _coordinateParserMock.Verify(x => x.TryParse("B4", out coordinate), Times.Once);
            _coordinateParserMock.Verify(x => x.Parse(It.IsAny <string>()), Times.Never);
            _coordinateParserMock.Verify(x => x.Parse("B4"), Times.Never);
        }
Exemple #2
0
        public GridBuilderIntegrationTests()
        {
            _configMock = new Mock <IOptions <AppSettings> >(MockBehavior.Strict);
            var randomWrapper = new RandomWrapper();
            var shipFactory   = new ShipFactory(_configMock.Object, randomWrapper);
            var grid          = new Logic.Grid.Grid();

            _sut = new GridBuilder(_configMock.Object, shipFactory, grid);
        }
Exemple #3
0
        public GameLogicIntegrationTests()
        {
            _configMock = new Mock <IOptions <AppSettings> >(MockBehavior.Strict);
            var settingsChecker     = new SettingsChecker(_configMock.Object);
            var randomWrapper       = new RandomWrapper();
            var shipFactory         = new ShipFactory(_configMock.Object, randomWrapper);
            var grid                = new Logic.Grid.Grid();
            var gridBuilder         = new GridBuilder(_configMock.Object, shipFactory, grid);
            var coordinateValidator = new CoordinateValidator();
            var coordinateParser    = new CoordinateParser(coordinateValidator);

            _sut = new GameLogic(settingsChecker, gridBuilder, coordinateParser);
        }
Exemple #4
0
        public void StartNewGame_EvertyhingOk_RightGridSize()
        {
            _settingsCheckerMock.Setup(x => x.Check())
            .Returns(ValidationResult.Success);
            var grid = new Logic.Grid.Grid();

            grid.Build(10, 8);
            _gridBuilderMock.Setup(x => x.Build())
            .Returns(grid);

            var result = _sut.StartNewGame();

            result.Success.Should().BeTrue();
            result.ErrorDescription.Should().BeNull();
            result.Content.ColumnCount.Should().Be(10);
            result.Content.RowCount.Should().Be(8);
        }
        public void StartNewGame_EvertyhingOk_RightGridSize()
        {
            _settingsCheckerMock.Setup(x => x.Check())
            .Returns(ValidationResult.Success);
            var grid = new Logic.Grid.Grid();

            grid.Build(10, 8);
            _gridBuilderMock.Setup(x => x.Build())
            .Returns(grid);

            var result = _sut.StartNewGame();

            result.Success.Should().BeTrue();
            result.ErrorDescription.Should().BeNull();
            result.Content.ColumnCount.Should().Be(10);
            result.Content.RowCount.Should().Be(8);

            _settingsCheckerMock.Verify(x => x.Check(), Times.Once);
            _gridBuilderMock.Verify(x => x.Build(), Times.Once);
            _coordinateParserMock.Verify(x => x.Parse(It.IsAny <string>()), Times.Never);
        }
Exemple #6
0
 public GridTests()
 {
     _sut = new Logic.Grid.Grid();
 }