diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-26 22:12:37 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-26 22:12:37 +0100 |
commit | 20625511ff872404e70984f5b21e3f514793c511 (patch) | |
tree | 521803194965ae4ef633f4c12003472d573c4b84 /game-engine/src/test | |
parent | Add board and played cards (diff) | |
download | seven-wonders-20625511ff872404e70984f5b21e3f514793c511.tar.gz seven-wonders-20625511ff872404e70984f5b21e3f514793c511.tar.bz2 seven-wonders-20625511ff872404e70984f5b21e3f514793c511.zip |
Add support for multiple columns
Diffstat (limited to 'game-engine/src/test')
-rw-r--r-- | game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/BoardsKtTest.kt | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/BoardsKtTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/BoardsKtTest.kt new file mode 100644 index 00000000..5cf60eaf --- /dev/null +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/api/BoardsKtTest.kt @@ -0,0 +1,84 @@ +package org.luxons.sevenwonders.game.api + +import org.junit.Test + +import org.junit.Assert.* +import org.luxons.sevenwonders.game.cards.Color +import org.luxons.sevenwonders.game.test.testCard + +class BoardsKtTest { + + @Test + fun `toColumns on empty list should return no cols`() { + val cols = emptyList<TableCard>().toColumns() + assertEquals(emptyList<List<TableCard>>(), cols) + } + + @Test + fun `toColumns with single resource should return a single column`() { + val card = testCard(color = Color.BROWN).toTableCard() + val cols = listOf(card).toColumns() + assertEquals(listOf(listOf(card)), cols) + } + + @Test + fun `toColumns with single non-resource should return a single column`() { + val card = testCard(color = Color.BLUE).toTableCard() + val cols = listOf(card).toColumns() + assertEquals(listOf(listOf(card)), cols) + } + + @Test + fun `toColumns with two same-color cards should return a single column`() { + val card1 = testCard(color = Color.BLUE).toTableCard() + val card2 = testCard(color = Color.BLUE).toTableCard() + val cards = listOf(card1, card2) + val cols = cards.toColumns() + assertEquals(listOf(cards), cols) + } + + @Test + fun `toColumns with two resource cards should return a single column`() { + val card1 = testCard(color = Color.BROWN).toTableCard() + val card2 = testCard(color = Color.GREY).toTableCard() + val cards = listOf(card1, card2) + val cols = cards.toColumns() + assertEquals(listOf(cards), cols) + } + + @Test + fun `toColumns with 2 different non-resource cards should return 2 columns`() { + val card1 = testCard(color = Color.BLUE).toTableCard() + val card2 = testCard(color = Color.GREEN).toTableCard() + val cards = listOf(card1, card2) + val cols = cards.toColumns() + assertEquals(listOf(listOf(card1), listOf(card2)), cols) + } + + @Test + fun `toColumns with 1 res and 1 non-res card should return 2 columns`() { + val card1 = testCard(color = Color.BROWN).toTableCard() + val card2 = testCard(color = Color.GREEN).toTableCard() + val cards = listOf(card1, card2) + val cols = cards.toColumns() + assertEquals(listOf(listOf(card1), listOf(card2)), cols) + } + + @Test + fun `toColumns should return 1 col for res cards and 1 for each other color`() { + val res1 = testCard(color = Color.BROWN).toTableCard() + val res2 = testCard(color = Color.BROWN).toTableCard() + val res3 = testCard(color = Color.GREY).toTableCard() + val blue1 = testCard(color = Color.BLUE).toTableCard() + val green1 = testCard(color = Color.GREEN).toTableCard() + val green2 = testCard(color = Color.GREEN).toTableCard() + val cards = listOf(res1, green1, green2, res2, blue1, res3) + val cols = cards.toColumns() + val expectedCols = listOf( + listOf(res1, res2, res3), + listOf(blue1), + listOf(green1, green2) + ) + assertEquals(expectedCols, cols) + } +} |