|
@ -57,5 +57,19 @@ class PlayerManagerTest { |
|
|
Arguments.of("MorePlayersInFileReturnLongerList", "Tobias;50\nLorenz;40\nSteffen;60", "src/test/java/resources/player_testdata.csv", |
|
|
Arguments.of("MorePlayersInFileReturnLongerList", "Tobias;50\nLorenz;40\nSteffen;60", "src/test/java/resources/player_testdata.csv", |
|
|
List.of(new Player("Tobias", 50), new Player("Lorenz", 40), new Player("Steffen", 60)))); |
|
|
List.of(new Player("Tobias", 50), new Player("Lorenz", 40), new Player("Steffen", 60)))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("testCasesForSavePlayers") |
|
|
|
|
|
void savePlayersTest(String testName, String fileName, List<Player> expectedResult) { |
|
|
|
|
|
manager.setPlayers(expectedResult); |
|
|
|
|
|
manager.savePlayers(fileName); |
|
|
|
|
|
manager.loadPlayers(fileName); |
|
|
|
|
|
List<Player> calculatedResult = manager.getPlayers(); |
|
|
|
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForSavePlayers() { |
|
|
|
|
|
return Stream.of(Arguments.of("EmptyListIsWrittenAsEmptyFile", "src/test/java/resources/player_testdata2.csv", List.of())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |