public BattleshipPlan BattleshipPlan()
        {
            var cells = new BattleshipCell[2, 4];

            for (var i = 0; i < 4; i++)
            {
                cells[0, i] = new BattleshipCell(CellNameBuilder.ToName(0, i), 0, i);
                cells[1, i] = new BattleshipCell(CellNameBuilder.ToName(1, i), 1, i);
            }

            var ship = new Battleship
            {
                ShipType = ShipType.Destroyer,
                Cells    = Enumerable.Range(0, 4).Select(e => cells[0, e]).ToArray()
            };

            foreach (var cell in ship.Cells)
            {
                cell.Assign();
            }

            return(new BattleshipPlan
            {
                Cells = cells,
                Ships = new [] { ship },
                Columns = 2,
                Rows = 4
            });
        }
Example #2
0
        public void Should_ToName_ReturnCorrectNameForGivenIndexes(int column, int row, string expectedName)
        {
            // Arrange
            // Act
            var actual = CellNameBuilder.ToName(column, row);

            // Assert
            actual.Should().Be(expectedName);
        }
Example #3
0
        public void Should_FromName_ReturnCorrectIndexesGivenName(string name, int expectedColumn, int expectedRow)
        {
            // Arrange
            // Act
            var(column, row) = CellNameBuilder.FromName(name);

            // Assert
            column.Should().Be(expectedColumn);
            row.Should().Be(expectedRow);
        }