public void TestCellValue_Reveal() { MinesweeperCell cell = new MinesweeperCell('A', false); cell.Reveal(); Assert.AreEqual(true, cell.IsRevealed); }
public void GetCell_TestWithValidCellPosition() { int gridRows = 10, gridCols = 10, minesCount = 4; MinesweeperGrid grid = new MinesweeperGrid(gridRows, gridCols, minesCount); MinesweeperCell cell = grid.GetCell(1, 1); Assert.AreEqual(MinesweeperCell.EmptyCell, cell.Value); }
public void GetCell_TestWithInvalidCellPosition_ShouldThrowException() { int gridRows = 10, gridCols = 10, minesCount = 4; MinesweeperGrid grid = new MinesweeperGrid(gridRows, gridCols, minesCount); MinesweeperCell cell = grid.GetCell(10, 1); }
private void _populateBoard() { var rand = new Random(); var mineProbability = (double) NumMines / ( Width * Height ); var mined = new MinesweeperCell[NumMines]; var currNumMines = 0; for (var i = 0; i < Height; i++) { for (var j = 0; j < Width; j++) { var index = i * Width + j; if (index < NumMines) { var cell = new MinesweeperCell(i, j, CellType.Mined); this[i, j] = cell; mined[currNumMines] = cell; currNumMines++; continue; } if (rand.NextDouble() < (double) NumMines / index) { //swap current cell randomly into the list of mined cells var select = rand.Next(mined.Length); mined[select].Type = CellType.Safe; this[i, j] = new MinesweeperCell(i, j, CellType.Mined); mined[select] = this[i, j]; continue; } this[i, j] = new MinesweeperCell(i, j, CellType.Safe); } } }
public void TestGetCellValue_When_Not_Revealed() { MinesweeperCell cell = new MinesweeperCell('A', false); Assert.AreEqual('?', cell.GetCellValue); }
public void TestCell_Constructor_With_Params_IsRevealed() { MinesweeperCell cell = new MinesweeperCell('A', true); Assert.AreEqual(true, cell.IsRevealed); }
public void TestCell_Constructor_With_Params_Value() { MinesweeperCell cell = new MinesweeperCell('A', true); Assert.AreEqual('A', cell.Value); }