From 32447ac27a5875e8f7cab0637b52a2ed2c6d87c4 Mon Sep 17 00:00:00 2001 From: Tobias Krause Date: Tue, 21 Dec 2021 14:29:27 +0100 Subject: [PATCH] gameexplorer: added new class player --- .../java/de/tims/gameexplorer/Player.java | 20 +++++++++++++ .../java/de/tims/gameexplorer/PlayerTest.java | 28 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/java/de/tims/gameexplorer/Player.java create mode 100644 src/test/java/de/tims/gameexplorer/PlayerTest.java diff --git a/src/main/java/de/tims/gameexplorer/Player.java b/src/main/java/de/tims/gameexplorer/Player.java new file mode 100644 index 0000000..b0d8f52 --- /dev/null +++ b/src/main/java/de/tims/gameexplorer/Player.java @@ -0,0 +1,20 @@ +package de.tims.gameexplorer; + +public class Player { + + private int points; + + public Player(int points) { + this.points = points; + } + + public void addPoints(int pointsToAdd) { + // TODO Auto-generated method stub + + } + + public int getPoints() { + return this.points; + } + +} diff --git a/src/test/java/de/tims/gameexplorer/PlayerTest.java b/src/test/java/de/tims/gameexplorer/PlayerTest.java new file mode 100644 index 0000000..2864ecf --- /dev/null +++ b/src/test/java/de/tims/gameexplorer/PlayerTest.java @@ -0,0 +1,28 @@ +package de.tims.gameexplorer; + +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; + +class PlayerTest { + + Player player; + + @ParameterizedTest + @MethodSource("testCasesForAddPoints") + void test(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 testCasesForAddPoints() { + return Stream.of(Arguments.of("NoPointsBeforeGet0Points", 0, 0, 0)); + } + +}