From 6cb116e11443639a7e5e65b5f7784be67e440339 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Mon, 8 May 2017 10:05:26 +0200 Subject: Extract test method createRequirements() --- .../org/luxons/sevenwonders/game/cards/RequirementsTest.java | 9 ++------- .../test/java/org/luxons/sevenwonders/game/test/TestUtils.java | 7 +++++++ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'backend') diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java b/backend/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java index db8a016a..b46a5bb9 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/game/cards/RequirementsTest.java @@ -9,7 +9,6 @@ import org.junit.runner.RunWith; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.resources.ResourceType; -import org.luxons.sevenwonders.game.resources.Resources; import org.luxons.sevenwonders.game.test.TestUtils; import static org.junit.Assert.assertEquals; @@ -44,9 +43,7 @@ public class RequirementsTest { @Theory public void resourceRequirement_initialResource(ResourceType initialResource, ResourceType requiredResource) { - Resources resources = TestUtils.createResources(requiredResource); - Requirements requirements = new Requirements(); - requirements.setResources(resources); + Requirements requirements = TestUtils.createRequirements(requiredResource); Board board = TestUtils.createBoard(initialResource, 0); Table table = new Table(Collections.singletonList(board)); @@ -64,9 +61,7 @@ public class RequirementsTest { ResourceType requiredResource) { assumeTrue(initialResource != requiredResource); - Resources resources = TestUtils.createResources(requiredResource); - Requirements requirements = new Requirements(); - requirements.setResources(resources); + Requirements requirements = TestUtils.createRequirements(requiredResource); Board board = TestUtils.createBoard(initialResource, 0); board.getProduction().addFixedResource(producedResource, 1); diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/backend/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java index a206cfb8..08cb10e8 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java +++ b/backend/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java @@ -108,6 +108,13 @@ public class TestUtils { return boughtResources; } + public static Requirements createRequirements(ResourceType... types) { + Resources resources = createResources(types); + Requirements requirements = new Requirements(); + requirements.setResources(resources); + return requirements; + } + public static List createSampleCards(int fromIndex, int nbCards) { List sampleCards = new ArrayList<>(); for (int i = fromIndex; i < fromIndex + nbCards; i++) { -- cgit