public void Generate_WhenNewBoardIsGenerated_ShouldReturnValidNumberOfShips()
        {
            // Arrange
            var randomGridGenerator = new RandomGridGenerator();

            // Act
            var grid = randomGridGenerator.Generate(true);

            // Assert
            var numberOfShips       = 0;
            var numberOfEmptinesses = 0;

            for (int row = 0; row < 10; row++)
            {
                for (int column = 0; column < 10; column++)
                {
                    if (grid[row, column] == CellStatus.Ship)
                    {
                        numberOfShips++;
                    }
                    else if (grid[row, column] == CellStatus.Empty)
                    {
                        numberOfEmptinesses++;
                    }
                }
            }

            // 1x5 + 2x4 = 13
            Assert.AreEqual(13, numberOfShips);
            Assert.AreEqual(87, numberOfEmptinesses);
        }
Пример #2
0
        /// <summary>
        /// Creates a new game.
        /// </summary>
        /// <param name="power"></param>
        /// <returns></returns>
        public GameGrid NewRandomGridGame(int lineCount, int columnCount)
        {
            IGridGenerator gridGenerator = new RandomGridGenerator();

            GameGrid gg = gridGenerator.Generate <GameGrid>(lineCount, columnCount);

            return(gg);
        }