Browse Source

player_management: added method savePlayers

player_management
Tobias Krause 3 years ago
committed by Lorenz Hohmann
parent
commit
df6f48946e
  1. 5
      src/main/java/de/tims/player_management/PlayerManager.java
  2. 14
      src/test/java/de/tims/player_management/PlayerManagerTest.java

5
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
}
}

14
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<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()));
}
}
Loading…
Cancel
Save