From 1155d7c0d32ed2d9e16a966e27400c70cdbd4802 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Mon, 17 Jan 2022 11:42:41 +0100 Subject: [PATCH] leaderboard: added method getTop10Players --- .../java/de/tims/leaderboard/Leaderboard.java | 17 ++++++++++ .../de/tims/leaderboard/LeaderboardTest.java | 31 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/java/de/tims/leaderboard/Leaderboard.java create mode 100644 src/test/java/de/tims/leaderboard/LeaderboardTest.java diff --git a/src/main/java/de/tims/leaderboard/Leaderboard.java b/src/main/java/de/tims/leaderboard/Leaderboard.java new file mode 100644 index 0000000..6f78e09 --- /dev/null +++ b/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 allPlayers, String actualPlayer) { + // TODO Auto-generated constructor stub + } + + public Player[] getTop10Players() { + return new Player[] {null, null, null, null, null, null, null, null, null, null}; + } + +} diff --git a/src/test/java/de/tims/leaderboard/LeaderboardTest.java b/src/test/java/de/tims/leaderboard/LeaderboardTest.java new file mode 100644 index 0000000..5e0fabc --- /dev/null +++ b/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 allPlayers, String actualPlayer, Player[] expectedResult) { + leaderboard = new Leaderboard(allPlayers, actualPlayer); + Player[] calculatedResutl = leaderboard.getTop10Players(); + + assertThat(calculatedResutl).describedAs(testName).isEqualTo(expectedResult); + } + + private static Stream testCasesForGetTop10Players() { + return Stream.of(Arguments.of("EmptyListReturnsEmptyArray", List.of(), "TestPlayer", new Player[] {null, null, null, null, null, null, null, null, null, null})); + } + +}