diff options
author | jbion <joffrey.bion@amadeus.com> | 2016-12-23 00:52:08 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2016-12-23 00:52:54 +0100 |
commit | 9efaf7909ba72607254ee9248b98f6cd5856b693 (patch) | |
tree | eb22a003ab37dcc2a75f28428aad723c5b5a73cd /src/test/java/org/luxons | |
parent | Add tests for equals and hashcode to maximize coverage in resources package (diff) | |
download | seven-wonders-9efaf7909ba72607254ee9248b98f6cd5856b693.tar.gz seven-wonders-9efaf7909ba72607254ee9248b98f6cd5856b693.tar.bz2 seven-wonders-9efaf7909ba72607254ee9248b98f6cd5856b693.zip |
Add brush test for game definition loading to ensure no exception occur
Diffstat (limited to 'src/test/java/org/luxons')
3 files changed, 60 insertions, 1 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java new file mode 100644 index 00000000..b38afd49 --- /dev/null +++ b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java @@ -0,0 +1,16 @@ +package org.luxons.sevenwonders.game.data; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class GameDefinitionLoaderTest { + + @Test + public void successfulLoad() throws Exception { + GameDefinitionLoader loader = new GameDefinitionLoader(); + GameDefinition gameDefinition = loader.getGameDefinition(); + assertNotNull(gameDefinition); + } + +}
\ No newline at end of file diff --git a/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java new file mode 100644 index 00000000..d610d793 --- /dev/null +++ b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java @@ -0,0 +1,26 @@ +package org.luxons.sevenwonders.game.data; + +import java.util.List; + +import org.junit.Test; +import org.luxons.sevenwonders.game.Game; +import org.luxons.sevenwonders.game.Player; +import org.luxons.sevenwonders.game.Settings; +import org.luxons.sevenwonders.game.test.TestUtils; + +import static org.junit.Assert.*; + +public class GameDefinitionTest { + + @Test + public void successfulGameInit() throws Exception { + GameDefinition gameDefinition = new GameDefinitionLoader().getGameDefinition(); + assertNotNull(gameDefinition); + + Settings settings = new Settings(); + settings.setNbPlayers(7); + List<Player> players = TestUtils.createPlayers(7); + Game game = gameDefinition.initGame(0, settings, players); + assertNotNull(game); + } +}
\ No newline at end of file diff --git a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java index 66a8e7c6..3717d3ad 100644 --- a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java +++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java @@ -3,6 +3,7 @@ package org.luxons.sevenwonders.game.test; import java.util.ArrayList; import java.util.List; +import org.luxons.sevenwonders.game.Player; import org.luxons.sevenwonders.game.Settings; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; @@ -30,10 +31,26 @@ public class TestUtils { return boards; } + public static List<Player> createPlayers(int count) { + List<Player> players = new ArrayList<>(count); + for (int i = 0; i < count; i++) { + String userName = "testUser" + i; + String displayName = "Test User " + i; + Player player = new Player(displayName, userName); + players.add(player); + } + return players; + } + public static Board createBoard(ResourceType initialResource) { Settings settings = new Settings(); Wonder wonder = new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource); - return new Board(wonder, null, settings); + + String userName = "testUser" + initialResource.getSymbol(); + String displayName = "Test User " + initialResource.getSymbol(); + Player player = new Player(displayName, userName); + + return new Board(wonder, player, settings); } public static Board createBoard(ResourceType initialResource, ResourceType... production) { |