diff options
Diffstat (limited to 'test/jrummikub')
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 38 | ||||
-rw-r--r-- | test/jrummikub/view/MockTablePanel.java | 2 |
2 files changed, 34 insertions, 6 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 7d13ff0..5b95ab2 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -6,11 +6,16 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; + +import java.util.Iterator; + +import jrummikub.model.GameState; import jrummikub.model.MockGameState; import jrummikub.model.MockTable; import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.model.StoneSet; +import jrummikub.util.Pair; import jrummikub.view.MockView; import org.junit.Before; @@ -20,16 +25,22 @@ public class RoundControlTest { private MockView view; private MockGameState testGameState; private RoundControl testRound; + private MockTable newTable; @Before public void setup() { view = new MockView(); testGameState = new MockGameState(); testRound = new RoundControl(testGameState, view); + Stone stone = testGameState.getGameHeap().drawStone(); + testGameState.table.drop(new StoneSet(stone), new Position(5, 0)); + newTable = new MockTable(); + newTable.drop(new StoneSet(stone), new Position(5, 0)); + } private void checkCorrectlyDealed() { - assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState + assertEquals(106 - testGameState.getPlayerCount() * 14 - testGameState.table.getSize(), testGameState .getGameHeap().getSize()); for (int i = 0; i < testGameState.getPlayerCount(); i++) { assertEquals(14, testGameState.getPlayer(i).getHand().getSize()); @@ -43,6 +54,18 @@ public class RoundControlTest { assertNotNull(view.getTablePanel().rightPlayerName); assertTrue(view.displayStartTurnPanel); assertFalse(view.startTurnEvent.listeners.isEmpty()); + checkTableDisplay(); + } + + private void checkTableDisplay() { + Iterator<Pair<StoneSet, Position>> stoneSetsView = view.tablePanel.stoneSets.iterator(); + Iterator<Pair<StoneSet, Position>> stoneSetsModel = testGameState.table.sets.iterator(); + + while(stoneSetsView.hasNext()) { + assertTrue(stoneSetsModel.hasNext()); + assertSame(stoneSetsView.next(), stoneSetsModel.next()); + } + assertFalse(stoneSetsModel.hasNext()); } private void resetTurnStart() { @@ -66,12 +89,19 @@ public class RoundControlTest { checkTurnStartSetUp(); } + + @Test + public void testStartRoundDisplayOnly() { + testRound.startRound(); + checkCorrectlyDealed(); + + checkTableDisplay(); + } @Test public void testTableValidHandChanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; @@ -92,7 +122,6 @@ public class RoundControlTest { public void testTableInvalidHandChanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = false; oldTable.clonedTable = newTable; @@ -114,7 +143,6 @@ public class RoundControlTest { public void testTableValidHandUnchanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; @@ -135,7 +163,6 @@ public class RoundControlTest { public void testTableInvalidHandUnchanged() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = false; oldTable.clonedTable = newTable; @@ -156,7 +183,6 @@ public class RoundControlTest { public void testWinning() { testRound.startRound(); MockTable oldTable = testGameState.table; - MockTable newTable = new MockTable(); newTable.valid = true; oldTable.clonedTable = newTable; diff --git a/test/jrummikub/view/MockTablePanel.java b/test/jrummikub/view/MockTablePanel.java index 65842c2..151cc7e 100644 --- a/test/jrummikub/view/MockTablePanel.java +++ b/test/jrummikub/view/MockTablePanel.java @@ -21,6 +21,8 @@ public class MockTablePanel implements ITablePanel { public String leftPlayerName; public String topPlayerName; public String rightPlayerName; + + public Iterable<Pair<StoneSet, Position>> stoneSets; @Override public IEvent2<Stone, Boolean> getStoneClickEvent() { |