You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import static org.assertj.core.api.Assertions.*;
  2. import org.junit.jupiter.api.BeforeEach;
  3. import org.junit.jupiter.api.DisplayName;
  4. import org.junit.jupiter.api.Test;
  5. import org.junit.jupiter.params.ParameterizedTest;
  6. import org.junit.jupiter.params.provider.Arguments;
  7. import org.junit.jupiter.params.provider.MethodSource;
  8. public class PlayerTest {
  9. private Player p;
  10. @BeforeEach
  11. void setup() {
  12. p = new Player("Rot");
  13. }
  14. @Test
  15. void testDice() {
  16. int calculatedResult = p.rollDice();
  17. assertThat(calculatedResult).describedAs("Dice result").isBetween(1,6);
  18. }
  19. @Test
  20. void testToString() {
  21. String expectedResult = "Rot";
  22. String calculatedResult = p.toString();
  23. assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult);
  24. }
  25. @Test
  26. void checkStartPositionOfFigures() {
  27. int expectedResult = -1;
  28. int calculatedResult = p.figures[0].position;
  29. for(int i = 0; i < 4; i++) {
  30. calculatedResult = p.figures[i].position;
  31. if(expectedResult != calculatedResult) {
  32. calculatedResult = 1;
  33. break;
  34. }
  35. }
  36. assertThat(calculatedResult).describedAs("Starting postion of Figures").isEqualTo(expectedResult);
  37. }
  38. }