Nur die besten Spiele ;3
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

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<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)
);
}
}