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

  1. package Minesweeper;
  2. import static org.junit.jupiter.api.Assertions.*;
  3. import java.util.stream.Stream;
  4. import org.junit.jupiter.api.Test;
  5. import org.junit.jupiter.params.ParameterizedTest;
  6. import org.junit.jupiter.params.provider.Arguments;
  7. import org.junit.jupiter.params.provider.MethodSource;
  8. class MinesweeperGameTest {
  9. @ParameterizedTest
  10. @MethodSource("testBombs")
  11. void testBombPlacement(int _playfieldSize, int _bombAmount) {
  12. MinesweeperGame m = new MinesweeperGame(_playfieldSize, _bombAmount);
  13. int bombCounter = 0;
  14. for(Cell[] row : m.playfield.cells){
  15. for (Cell c : row) {
  16. if(c.type == CellType.Bomb) {
  17. bombCounter++;
  18. }
  19. }
  20. }
  21. assertEquals(_bombAmount, bombCounter);
  22. }
  23. @Test
  24. void testProximityPoints() {
  25. MinesweeperGame m = new MinesweeperGame(3, 0);
  26. m.playfield.cells[0][0].type = CellType.Bomb;
  27. m.playfield.calculateBombProximity(1, 1);
  28. assertEquals(1, m.playfield.cells[1][1].value);
  29. }
  30. private static Stream<Arguments> testBombs(){
  31. return Stream.of(
  32. Arguments.of(8, 10),
  33. Arguments.of(8, 0),
  34. Arguments.of(4, 12),
  35. Arguments.of(10, 100),
  36. Arguments.of(5, 1)
  37. );
  38. }
  39. }