|
|
@ -0,0 +1,34 @@ |
|
|
|
package de.tims.player_management; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.*; |
|
|
|
|
|
|
|
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 PlayerTest { |
|
|
|
|
|
|
|
Player player; |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("testCasesForAddPoints") |
|
|
|
void addPointsTest(String testName, int pointsBefore, int pointsToAdd, int expectedResult) { |
|
|
|
player = new Player(pointsBefore); |
|
|
|
player.addPoints(pointsToAdd); |
|
|
|
int calculatedResult = player.getPoints(); |
|
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
private static Stream<Arguments> testCasesForAddPoints() { |
|
|
|
return Stream.of(Arguments.of("NoPointsBeforeGet0Points", 0, 0, 0), |
|
|
|
Arguments.of("NoPointsBeforeGet10Points", 0, 10, 10), |
|
|
|
Arguments.of("10PointsBeforeAdd10Points", 10, 10, 20), |
|
|
|
Arguments.of("10PointsBeforeLose10Points", 10, -10, 0), |
|
|
|
Arguments.of("LoseMorePointsThanYouHave", 10, -20, 0)); |
|
|
|
} |
|
|
|
|
|
|
|
} |