public void TestRevealNumberWithEightBombs() { // Create a Test Field int testRow = 5; int testCall = 10; int mines = 15; string[,] testMineFiled = new string[testRow, testCall]; IField mineFieldTest = new Minesweeper.Field(testRow, testCall, mines); mineFieldTest.GetDefaultField(); // bombs All Around for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { testMineFiled[i, j] += "*"; } } testMineFiled[1, 1] += string.Empty; int revialedCells = 0; string expectedRevealNumber = "8"; mineFieldTest.RevialCell(1, 1); if (testMineFiled[1, 1] == string.Empty) { int[] directionRow = { 1, 1, 1, 0, -1, -1, -1, 0 }; int[] directionCol = { 1, 0, -1, -1, -1, 0, 1, 1 }; int minesCounterRevealNumber = 0; for (int direction = 0; direction < 8; direction++) { int newRow = directionRow[direction] + 1; int newCol = directionCol[direction] + 0; if (mineFieldTest.IsMoveInBounds(newRow, newCol)) { if (testMineFiled[newRow, newCol] == "*") { minesCounterRevealNumber++; } } } testMineFiled[1, 0] = Convert.ToString(minesCounterRevealNumber); string result = testMineFiled[1, 0]; revialedCells++; Assert.AreEqual(expectedRevealNumber, result); } }
public void TestGetDefaultFieldMethodNegative() { int row = 5; int call = 10; int mines = 15; string[,] testMineFiled = new string[row, call]; string emptySymbol = " "; IField mineFieldTest = new Minesweeper.Field(row, call, mines); mineFieldTest.GetDefaultField(); for (int i = 0; i < row; i++) { for (int j = 0; j < call; j++) { testMineFiled[i, j] = string.Empty; Assert.AreNotEqual(emptySymbol, testMineFiled[i, j]); } } }