summaryrefslogtreecommitdiff
path: root/game-engine/src/test/kotlin/org/luxons
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2018-07-08 12:28:44 +0200
committerjbion <joffrey.bion@amadeus.com>2018-07-08 12:29:20 +0200
commit4595481f15d7e1e9ee244f4e985650a3ed03a8fd (patch)
treed6ae3a55f3f83a30109c864ed06743583590b995 /game-engine/src/test/kotlin/org/luxons
parentKotlin mig: Game tests (diff)
downloadseven-wonders-4595481f15d7e1e9ee244f4e985650a3ed03a8fd.tar.gz
seven-wonders-4595481f15d7e1e9ee244f4e985650a3ed03a8fd.tar.bz2
seven-wonders-4595481f15d7e1e9ee244f4e985650a3ed03a8fd.zip
Kotlin mig: api package tests
Diffstat (limited to 'game-engine/src/test/kotlin/org/luxons')
-rw-r--r--game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/TableTest.kt85
1 files changed, 85 insertions, 0 deletions
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)
+ }
+ }
+}
bgstack15