From ec29bc93f5b2d332ff68aab6ba20fcc56fa739c5 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 8 Feb 2022 08:41:08 +0100 Subject: [PATCH] Refactor GameTest Player init --- src/test/java/GameTest.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index 036b7db..a7b9bf7 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -13,64 +13,60 @@ import java.util.stream.Stream; public class GameTest { private Game g; + private Player p; @BeforeEach void setup() { g = new Game(); + p = new Player("Rot", 1, 40, 43); } @ParameterizedTest @MethodSource("checkDiceTestData") - void checkDiceTest(String testname, Player testPlayer, Collection positions, int dice, int c, boolean expectedResult) { - Iterator
it = testPlayer.figures.iterator(); + void checkDiceTest(String testname, Collection positions, int dice, int c, boolean expectedResult) { + Iterator
it = p.figures.iterator(); Iterator it2 = positions.iterator(); while(it.hasNext()) { it.next().setPosition(it2.next()); } - boolean calculatedResult = g.checkDice(dice, testPlayer, c); + boolean calculatedResult = g.checkDice(dice, p, c); assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); } static Stream checkDiceTestData () { return Stream.of( Arguments.of("No figures on Field - d: 1 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 1, true ), Arguments.of("No figures on Field - d: 1 - c: 2", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 2, true ), Arguments.of("No figures on Field - d: 1 - c: 3", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 3, true ), Arguments.of("No figures on Field - d: 1 - c: 4", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 4, false ), Arguments.of("Figures on Field - d: 1 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(10, -1, 2, -1), 1, 1, false ), Arguments.of("Figures on Field - d: 6 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(10, -1, 2, -1), 6, 1,