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); }
/// <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); }
public void CreateTwoRandomGrids_SameRandomSeed() { var randomGenerator1 = new CustomDayGenerator(26, 04, 2020); var randomGenerator2 = new CustomDayGenerator(26, 04, 2020); var grid1 = RandomGridGenerator.GenerateRandomGrid(randomGenerator1); var grid2 = RandomGridGenerator.GenerateRandomGrid(randomGenerator2); AssertGridsEqual(grid1, grid2); }
public void CreateTwentyRandomGrids() { var randomGenerator = new CustomDayGenerator(26, 04, 2020); for (int i = 0; i < 20; i++) { Debug.Log(i + 1); var grid = RandomGridGenerator.GenerateRandomGrid(randomGenerator); PrintGrid(grid); } }
public void When_RandomGridGenerated_Expect_NoEmptyTiles() { var grid = new Grid(5, 5); var generator = new RandomGridGenerator(); generator.Seed = 45678; generator.GenerateGrid(grid); for (var x = 0; x < grid.Size.Width; x++) { for (var y = 0; y < grid.Size.Height; y++) { Assert.That(grid.GetTile(x, y).Type != TileType.Empty); } } }