package Minesweeper; import static org.junit.jupiter.api.Assertions.*; import java.util.stream.Stream; import org.junit.jupiter.api.Test; 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.cells){ for (Cell c : row) { if(c.type == CellType.Bomb) { bombCounter++; } } } assertEquals(_bombAmount, bombCounter); } @Test void testProximityPoints() { MinesweeperGame m = new MinesweeperGame(3, 0); m.playfield.cells[0][0].type = CellType.Bomb; m.playfield.calculateBombProximity(1, 1); assertEquals(1, m.playfield.cells[1][1].value); } private static Stream testBombs(){ return Stream.of( Arguments.of(8, 10), Arguments.of(8, 0), Arguments.of(4, 12), Arguments.of(10, 100), Arguments.of(5, 1) ); } }