kfkama
3 years ago
2 changed files with 69 additions and 6 deletions
-
34src/main/java/Minesweeper/MinesweeperGame.java
-
41src/test/java/Minesweeper/MinesweeperGameTest.java
@ -0,0 +1,41 @@ |
|||
package Minesweeper; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
import java.util.stream.Stream; |
|||
|
|||
import org.junit.jupiter.params.ParameterizedTest; |
|||
import org.junit.jupiter.params.provider.Arguments; |
|||
import org.junit.jupiter.params.provider.MethodSource; |
|||
|
|||
class MinesweeperGameTest { |
|||
|
|||
@ParameterizedTest |
|||
@MethodSource("testBombs") |
|||
void testBombPlacement(int _playfieldSize, int _bombAmount) { |
|||
MinesweeperGame m = new MinesweeperGame(_playfieldSize, _bombAmount); |
|||
|
|||
int bombCounter = 0; |
|||
|
|||
for(Cell[] row : m.playfield){ |
|||
for (Cell c : row) { |
|||
if(c.type == CellType.Bomb) { |
|||
bombCounter++; |
|||
} |
|||
} |
|||
} |
|||
assertEquals(_bombAmount, bombCounter); |
|||
} |
|||
|
|||
|
|||
private static Stream<Arguments> testBombs(){ |
|||
return Stream.of( |
|||
Arguments.of(8, 10), |
|||
Arguments.of(8, 0), |
|||
Arguments.of(4, 12), |
|||
Arguments.of(10, 100), |
|||
Arguments.of(5, 1) |
|||
); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue