diff options
Diffstat (limited to 'game-engine')
-rw-r--r-- | game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java | 86 | ||||
-rw-r--r-- | game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt | 85 |
2 files changed, 85 insertions, 86 deletions
diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java deleted file mode 100644 index 0dfa3a80..00000000 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/api/TableTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.luxons.sevenwonders.game.api; - -import java.util.List; - -import org.junit.experimental.theories.DataPoints; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; -import org.luxons.sevenwonders.game.boards.RelativeBoardPosition; -import org.luxons.sevenwonders.game.cards.Card; -import org.luxons.sevenwonders.game.test.TestUtilsKt; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - -@RunWith(Theories.class) -public class TableTest { - - @DataPoints - public static int[] nbPlayers() { - return new int[] {2, 3, 4, 5, 6, 7, 8}; - } - - @Theory - public void getBoard_wrapLeft(int nbPlayers) { - assumeTrue(nbPlayers >= 2); - Table table = TestUtilsKt.testTable(nbPlayers); - int last = nbPlayers - 1; - assertEquals(table.getBoard(last), table.getBoard(0, RelativeBoardPosition.LEFT)); - assertEquals(table.getBoard(0), table.getBoard(0, RelativeBoardPosition.SELF)); - assertEquals(table.getBoard(1), table.getBoard(0, RelativeBoardPosition.RIGHT)); - } - - @Theory - public void getBoard_wrapRight(int nbPlayers) { - assumeTrue(nbPlayers >= 2); - Table table = TestUtilsKt.testTable(nbPlayers); - int last = nbPlayers - 1; - assertEquals(table.getBoard(last - 1), table.getBoard(last, RelativeBoardPosition.LEFT)); - assertEquals(table.getBoard(last), table.getBoard(last, RelativeBoardPosition.SELF)); - assertEquals(table.getBoard(0), table.getBoard(last, RelativeBoardPosition.RIGHT)); - } - - @Theory - public void getBoard_noWrap(int nbPlayers) { - assumeTrue(nbPlayers >= 3); - Table table = TestUtilsKt.testTable(nbPlayers); - assertEquals(table.getBoard(0), table.getBoard(1, RelativeBoardPosition.LEFT)); - assertEquals(table.getBoard(1), table.getBoard(1, RelativeBoardPosition.SELF)); - assertEquals(table.getBoard(2), table.getBoard(1, RelativeBoardPosition.RIGHT)); - } - - @Theory - public void getNeighbourGuildCards(int nbPlayers) { - assumeTrue(nbPlayers >= 4); - Table table = TestUtilsKt.testTable(nbPlayers); - List<Card> guildCards = TestUtilsKt.createGuildCards(4); - table.getBoard(0).getPlayedCards().add(guildCards.get(0)); - table.getBoard(0).getPlayedCards().add(guildCards.get(1)); - table.getBoard(1).getPlayedCards().add(guildCards.get(2)); - table.getBoard(2).getPlayedCards().add(guildCards.get(3)); - - List<Card> neightbourCards0 = table.getNeighbourGuildCards(0); - assertEquals(1, neightbourCards0.size()); - assertFalse(neightbourCards0.contains(guildCards.get(0))); - assertFalse(neightbourCards0.contains(guildCards.get(1))); - assertTrue(neightbourCards0.contains(guildCards.get(2))); - assertFalse(neightbourCards0.contains(guildCards.get(3))); - - List<Card> neightbourCards1 = table.getNeighbourGuildCards(1); - assertEquals(3, neightbourCards1.size()); - assertTrue(neightbourCards1.contains(guildCards.get(0))); - assertTrue(neightbourCards1.contains(guildCards.get(1))); - assertFalse(neightbourCards1.contains(guildCards.get(2))); - assertTrue(neightbourCards1.contains(guildCards.get(3))); - - List<Card> neightbourCards2 = table.getNeighbourGuildCards(2); - assertEquals(1, neightbourCards2.size()); - assertFalse(neightbourCards2.contains(guildCards.get(0))); - assertFalse(neightbourCards2.contains(guildCards.get(1))); - assertTrue(neightbourCards2.contains(guildCards.get(2))); - assertFalse(neightbourCards2.contains(guildCards.get(3))); - } -} diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt new file mode 100644 index 00000000..ab4655ce --- /dev/null +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt @@ -0,0 +1,85 @@ +package org.luxons.sevenwonders.game.api + +import org.junit.Assert.* +import org.junit.Assume.assumeTrue +import org.junit.experimental.theories.DataPoints +import org.junit.experimental.theories.Theories +import org.junit.experimental.theories.Theory +import org.junit.runner.RunWith +import org.luxons.sevenwonders.game.boards.RelativeBoardPosition +import org.luxons.sevenwonders.game.test.createGuildCards +import org.luxons.sevenwonders.game.test.testTable + +@RunWith(Theories::class) +class TableTest { + + @Theory + fun getBoard_wrapLeft(nbPlayers: Int) { + assumeTrue(nbPlayers >= 2) + val table = testTable(nbPlayers) + val last = nbPlayers - 1 + assertEquals(table.getBoard(last), table.getBoard(0, RelativeBoardPosition.LEFT)) + assertEquals(table.getBoard(0), table.getBoard(0, RelativeBoardPosition.SELF)) + assertEquals(table.getBoard(1), table.getBoard(0, RelativeBoardPosition.RIGHT)) + } + + @Theory + fun getBoard_wrapRight(nbPlayers: Int) { + assumeTrue(nbPlayers >= 2) + val table = testTable(nbPlayers) + val last = nbPlayers - 1 + assertEquals(table.getBoard(last - 1), table.getBoard(last, RelativeBoardPosition.LEFT)) + assertEquals(table.getBoard(last), table.getBoard(last, RelativeBoardPosition.SELF)) + assertEquals(table.getBoard(0), table.getBoard(last, RelativeBoardPosition.RIGHT)) + } + + @Theory + fun getBoard_noWrap(nbPlayers: Int) { + assumeTrue(nbPlayers >= 3) + val table = testTable(nbPlayers) + assertEquals(table.getBoard(0), table.getBoard(1, RelativeBoardPosition.LEFT)) + assertEquals(table.getBoard(1), table.getBoard(1, RelativeBoardPosition.SELF)) + assertEquals(table.getBoard(2), table.getBoard(1, RelativeBoardPosition.RIGHT)) + } + + @Theory + fun getNeighbourGuildCards(nbPlayers: Int) { + assumeTrue(nbPlayers >= 4) + val table = testTable(nbPlayers) + val guildCards = createGuildCards(4) + table.getBoard(0).playedCards.add(guildCards[0]) + table.getBoard(0).playedCards.add(guildCards[1]) + table.getBoard(1).playedCards.add(guildCards[2]) + table.getBoard(2).playedCards.add(guildCards[3]) + + val neightbourCards0 = table.getNeighbourGuildCards(0) + assertEquals(1, neightbourCards0.size.toLong()) + assertFalse(neightbourCards0.contains(guildCards[0])) + assertFalse(neightbourCards0.contains(guildCards[1])) + assertTrue(neightbourCards0.contains(guildCards[2])) + assertFalse(neightbourCards0.contains(guildCards[3])) + + val neightbourCards1 = table.getNeighbourGuildCards(1) + assertEquals(3, neightbourCards1.size.toLong()) + assertTrue(neightbourCards1.contains(guildCards[0])) + assertTrue(neightbourCards1.contains(guildCards[1])) + assertFalse(neightbourCards1.contains(guildCards[2])) + assertTrue(neightbourCards1.contains(guildCards[3])) + + val neightbourCards2 = table.getNeighbourGuildCards(2) + assertEquals(1, neightbourCards2.size.toLong()) + assertFalse(neightbourCards2.contains(guildCards[0])) + assertFalse(neightbourCards2.contains(guildCards[1])) + assertTrue(neightbourCards2.contains(guildCards[2])) + assertFalse(neightbourCards2.contains(guildCards[3])) + } + + companion object { + + @JvmStatic + @DataPoints + fun nbPlayers(): IntArray { + return intArrayOf(2, 3, 4, 5, 6, 7, 8) + } + } +} |