Skip to content

Commit e278c17

Browse files
committed
Test: Added coverage for 4 lines because I want the 80%
1 parent e37ad64 commit e278c17

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

api/src/test/java/lab/en2b/quizapi/game/GameServiceTest.java

+20
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,24 @@ public void testGetGameModes(){
476476
assertFalse(gameService.getQuestionGameModes().isEmpty());
477477
}
478478

479+
@Test
480+
public void testGameSetQuestionCategoriesInvalidGameMode(){
481+
Game g = new Game();
482+
g.setGameMode(GameMode.KIWI_QUEST);
483+
assertThrows(IllegalStateException.class, () -> g.setQuestionCategoriesForCustom(List.of(QuestionCategory.GEOGRAPHY)));
484+
}
485+
@Test
486+
public void testGameSetQuestionCategoriesInvalidNullCategories(){
487+
Game g = new Game();
488+
g.setGameMode(GameMode.CUSTOM);
489+
assertThrows(IllegalArgumentException.class, () -> g.setQuestionCategoriesForCustom(null));
490+
}
491+
@Test
492+
public void testGameSetQuestionCategoriesInvalidEmptyCategories(){
493+
Game g = new Game();
494+
g.setGameMode(null);
495+
g.setGameMode(GameMode.CUSTOM);
496+
List<QuestionCategory> qc = new ArrayList<>();
497+
assertThrows(IllegalArgumentException.class, () -> g.setQuestionCategoriesForCustom(qc));
498+
}
479499
}

0 commit comments

Comments
 (0)