Browse Source

leaderboard: added method getTop10Players

leaderboard
Tobias Krause 3 years ago
committed by Lorenz Hohmann
parent
commit
1155d7c0d3
  1. 17
      src/main/java/de/tims/leaderboard/Leaderboard.java
  2. 31
      src/test/java/de/tims/leaderboard/LeaderboardTest.java

17
src/main/java/de/tims/leaderboard/Leaderboard.java

@ -0,0 +1,17 @@
package de.tims.leaderboard;
import java.util.List;
import de.tims.player_management.Player;
public class Leaderboard {
public Leaderboard(List<Player> allPlayers, String actualPlayer) {
// TODO Auto-generated constructor stub
}
public Player[] getTop10Players() {
return new Player[] {null, null, null, null, null, null, null, null, null, null};
}
}

31
src/test/java/de/tims/leaderboard/LeaderboardTest.java

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