diff options
Diffstat (limited to 'test/jrummikub')
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 38 | ||||
-rw-r--r-- | test/jrummikub/view/MockTablePanel.java | 12 |
2 files changed, 36 insertions, 14 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index c591563..bc0bb3d 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -4,23 +4,45 @@ import static org.junit.Assert.*; import jrummikub.model.GameState; import jrummikub.view.MockView; +import org.junit.Before; import org.junit.Test; public class RoundControlTest { + private MockView view; + private GameState testGameState; + private RoundControl testRound; - @Test - public void testDeal() { - MockView view = new MockView(); - GameState testGameState = new GameState(); - RoundControl testRound = new RoundControl(testGameState, view); - testRound.deal(); + @Before + public void setup() { + view = new MockView(); + testGameState = new GameState(); + testRound = new RoundControl(testGameState, view); + } + + private void checkCorrectlyDealed() { assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState .getGameHeap().getSize()); for (int i = 0; i < testGameState.getPlayerCount(); i++) { assertEquals(14, testGameState.getPlayer(i).getHand().getSize()); } } - - + @Test + public void testDeal() { + testRound.deal(); + checkCorrectlyDealed(); + } + + @Test + public void testStartRound() { + testRound.startRound(); + checkCorrectlyDealed(); + + assertNotNull(view.currentPlayerName); + assertNotNull(view.getTablePanel().leftPlayerName); + assertNotNull(view.getTablePanel().topPlayerName); + assertNotNull(view.getTablePanel().rightPlayerName); + assertTrue(view.displayStartTurnPanel); + assertFalse(view.startTurnEvent.listeners.isEmpty()); + } } diff --git a/test/jrummikub/view/MockTablePanel.java b/test/jrummikub/view/MockTablePanel.java index 04ff926..58ca9c6 100644 --- a/test/jrummikub/view/MockTablePanel.java +++ b/test/jrummikub/view/MockTablePanel.java @@ -12,6 +12,9 @@ import jrummikub.util.IEvent2; public class MockTablePanel implements ITablePanel { public MockStoneCollectionPanel stoneCollectionPanel = new MockStoneCollectionPanel(); + public String leftPlayerName; + public String topPlayerName; + public String rightPlayerName; @Override public IEvent2<Stone, Boolean> getStoneClickEvent() { @@ -39,20 +42,17 @@ public class MockTablePanel implements ITablePanel { @Override public void setLeftPlayerName(String playerName) { - // TODO Auto-generated method stub - + leftPlayerName = playerName; } @Override public void setTopPlayerName(String playerName) { - // TODO Auto-generated method stub - + topPlayerName = playerName; } @Override public void setRightPlayerName(String playerName) { - // TODO Auto-generated method stub - + rightPlayerName = playerName; } @Override |