Browse Source

gameexplorer: added new class player

gameexplorer
Tobias Krause 3 years ago
committed by Lorenz Hohmann
parent
commit
32447ac27a
  1. 20
      src/main/java/de/tims/gameexplorer/Player.java
  2. 28
      src/test/java/de/tims/gameexplorer/PlayerTest.java

20
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;
}
}

28
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<Arguments> testCasesForAddPoints() {
return Stream.of(Arguments.of("NoPointsBeforeGet0Points", 0, 0, 0));
}
}
Loading…
Cancel
Save