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.

41 lines
888 B

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