From df6f48946ed2eb4abbf153726c57edeb5bf670a4 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Tue, 11 Jan 2022 20:03:16 +0100 Subject: [PATCH] player_management: added method savePlayers --- .../de/tims/player_management/PlayerManager.java | 5 +++++ .../tims/player_management/PlayerManagerTest.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/de/tims/player_management/PlayerManager.java b/src/main/java/de/tims/player_management/PlayerManager.java index ce6ae39..fcf1443 100644 --- a/src/main/java/de/tims/player_management/PlayerManager.java +++ b/src/main/java/de/tims/player_management/PlayerManager.java @@ -71,4 +71,9 @@ public class PlayerManager { } } + public void savePlayers(String fileName) { + // TODO Auto-generated method stub + + } + } diff --git a/src/test/java/de/tims/player_management/PlayerManagerTest.java b/src/test/java/de/tims/player_management/PlayerManagerTest.java index ec7a5a9..ae7c9b0 100644 --- a/src/test/java/de/tims/player_management/PlayerManagerTest.java +++ b/src/test/java/de/tims/player_management/PlayerManagerTest.java @@ -57,5 +57,19 @@ class PlayerManagerTest { 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)))); } + + @ParameterizedTest + @MethodSource("testCasesForSavePlayers") + void savePlayersTest(String testName, String fileName, List expectedResult) { + manager.setPlayers(expectedResult); + manager.savePlayers(fileName); + manager.loadPlayers(fileName); + List calculatedResult = manager.getPlayers(); + assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); + } + + private static Stream testCasesForSavePlayers() { + return Stream.of(Arguments.of("EmptyListIsWrittenAsEmptyFile", "src/test/java/resources/player_testdata2.csv", List.of())); + } }