|
@ -0,0 +1,31 @@ |
|
|
|
|
|
package de.tims.leaderboard; |
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
|
|
|
|
import de.tims.player_management.Player; |
|
|
|
|
|
|
|
|
|
|
|
class LeaderboardTest { |
|
|
|
|
|
|
|
|
|
|
|
Leaderboard leaderboard; |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("testCasesForGetTop10Players") |
|
|
|
|
|
void getTop10PlayersTest(String testName, List<Player> allPlayers, String actualPlayer, Player[] expectedResult) { |
|
|
|
|
|
leaderboard = new Leaderboard(allPlayers, actualPlayer); |
|
|
|
|
|
Player[] calculatedResutl = leaderboard.getTop10Players(); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(calculatedResutl).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForGetTop10Players() { |
|
|
|
|
|
return Stream.of(Arguments.of("EmptyListReturnsEmptyArray", List.of(), "TestPlayer", new Player[] {null, null, null, null, null, null, null, null, null, null})); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |