|
@ -2,7 +2,7 @@ package de.tims.player_management; |
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
|
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.stream.Stream; |
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
@ -15,14 +15,19 @@ class PlayerManagerTest { |
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
@ParameterizedTest |
|
|
@MethodSource("testCasesForSelectPlayer") |
|
|
@MethodSource("testCasesForSelectPlayer") |
|
|
void selectPlayerTest(String testName, LinkedList<Player> players, String playerName, Player expectedResult) { |
|
|
|
|
|
|
|
|
void selectPlayerTest(String testName, List<Player> players, String playerName, Player expectedResult) { |
|
|
manager.setPlayers(players); |
|
|
manager.setPlayers(players); |
|
|
Player calculatedResult = manager.selectPlayer(playerName); |
|
|
Player calculatedResult = manager.selectPlayer(playerName); |
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForSelectPlayer() { |
|
|
private static Stream<Arguments> testCasesForSelectPlayer() { |
|
|
return Stream.of(Arguments.of("NoPlayersYet", new LinkedList<Player>(), "Tobias", new Player(0))); |
|
|
|
|
|
|
|
|
return Stream.of(Arguments.of("NoPlayersYetReturnNewPlayer", List.of(), |
|
|
|
|
|
"Tobias", new Player("Tobias", 0)), |
|
|
|
|
|
Arguments.of("NoPlayerWithNameInListReturnNewPlayer", List.of(new Player("Steffen", 40), new Player("Lorenz", 60)), |
|
|
|
|
|
"Tobias", new Player("Tobias", 0)), |
|
|
|
|
|
Arguments.of("PlayerWithNameInListReturnPlayerInList", List.of(new Player("Steffen", 40), new Player("Tobias", 50)), |
|
|
|
|
|
"Tobias", new Player("Tobias", 50))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |