diff options
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r-- | test/jrummikub/control/RoundControlTest.java | 127 |
1 files changed, 53 insertions, 74 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 9663f95..bc8dce9 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -1,15 +1,7 @@ package jrummikub.control; -import static jrummikub.model.StoneColor.BLACK; -import static jrummikub.model.StoneColor.BLUE; -import static jrummikub.model.StoneColor.ORANGE; -import static jrummikub.model.StoneColor.RED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static jrummikub.model.StoneColor.*; +import static org.junit.Assert.*; import java.awt.Color; import java.util.Arrays; @@ -76,10 +68,8 @@ public class RoundControlTest { gameSettings.getPlayerList().add(new PlayerSettings("Ida", Color.RED)); gameSettings.getPlayerList().add( new PlayerSettings("Matthias", Color.YELLOW)); - gameSettings.getPlayerList().add( - new PlayerSettings("Jannis", Color.GREEN)); - gameSettings.getPlayerList().add( - new PlayerSettings("Bennet", Color.BLACK)); + gameSettings.getPlayerList().add(new PlayerSettings("Jannis", Color.GREEN)); + gameSettings.getPlayerList().add(new PlayerSettings("Bennet", Color.BLACK)); roundState = new RoundState(gameSettings); roundControl = new RoundControl(roundState, view); } @@ -89,16 +79,13 @@ public class RoundControlTest { - testRoundState.table.getSize(), testRoundState.getGameHeap() .getSize()); for (int i = 0; i < testRoundState.getPlayerCount(); i++) { - assertEquals(14, testRoundState.getNthNextPlayer(i).getHand() - .getSize()); + assertEquals(14, testRoundState.getNthNextPlayer(i).getHand().getSize()); } } private void checkTurnStartSetUp() { assertNotNull(view.currentPlayerName); - assertNotNull(view.getTablePanel().leftPlayerName); - assertNotNull(view.getTablePanel().topPlayerName); - assertNotNull(view.getTablePanel().rightPlayerName); + // TODO Check player list in view assertTrue(view.displayStartTurnPanel); assertFalse(view.startTurnEvent.listeners.isEmpty()); assertFalse(view.displayWinPanel); @@ -120,9 +107,7 @@ public class RoundControlTest { private void resetTurnStart() { view.currentPlayerName = null; - view.getTablePanel().leftPlayerName = null; - view.getTablePanel().topPlayerName = null; - view.getTablePanel().rightPlayerName = null; + // TODO reset player list view.displayStartTurnPanel = false; } @@ -155,8 +140,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 6, hand.getSize()); } @@ -176,8 +161,8 @@ public class RoundControlTest { assertFalse(roundState.getActivePlayer().getLaidOut()); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 1, hand.getSize()); } @@ -224,8 +209,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(0, roundState.getTable().getSize()); assertEquals(14 + 9, hand.getSize()); } @@ -295,8 +280,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 6, hand.getSize()); } @@ -369,8 +354,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 7, hand.getSize()); } @@ -433,8 +418,8 @@ public class RoundControlTest { view.tablePanel.clickEvent.emit(new Position(0, 0)); view.playerPanel.endTurnEvent.emit(); - assertFalse(roundState - .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut()); + assertFalse(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); assertEquals(2, roundState.getTable().getSize()); assertEquals(14 + 3, hand.getSize()); } @@ -692,15 +677,12 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); Stone blueFour = new Stone(4, BLUE); - StoneSet oldSet1 = new StoneSet( - Arrays.asList(blueOne, redOne, blackOne)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne)); StoneSet oldSet2 = new StoneSet(blueTwo); oldTable.drop(oldSet1, new Position(0, 0)); oldTable.drop(oldSet2, new Position(0, 0)); - StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, - blueFour)); - StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, - blueThree)); + StoneSet newSet1 = new StoneSet(Arrays.asList(blueOne, blueTwo, blueFour)); + StoneSet newSet2 = new StoneSet(Arrays.asList(redOne, blackOne, blueThree)); newTable.drop(newSet1, new Position(0, 0)); newTable.drop(newSet2, new Position(0, 0)); @@ -725,15 +707,14 @@ public class RoundControlTest { Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); Stone blueFour = new Stone(4, BLUE); - StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, - blackOne, orangeOne)); - StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, - blueFour)); + StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne, blackOne, + orangeOne)); + StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blueThree, blueFour)); oldTable.drop(oldSet1, new Position(0, 0)); oldTable.drop(oldSet2, new Position(0, 0)); ITable newTable = (Table) oldTable.clone(); - List<StoneSet> newSets = RoundControl.tableSetDifference(oldTable, - newTable); + List<StoneSet> newSets = RoundControl + .tableSetDifference(oldTable, newTable); List<StoneSet> vanishedSets = RoundControl.tableSetDifference(newTable, oldTable); @@ -741,8 +722,8 @@ public class RoundControlTest { assertTrue(vanishedSets.isEmpty()); newTable.pickUp(oldSet2); - newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), - new Position(0, 0)); + newTable.drop(oldSet2.join(new StoneSet(new Stone(5, BLUE))), new Position( + 0, 0)); newSets = RoundControl.tableSetDifference(oldTable, newTable); vanishedSets = RoundControl.tableSetDifference(newTable, oldTable); @@ -754,8 +735,7 @@ public class RoundControlTest { Stone redTwo = new Stone(2, RED); Stone redThree = new Stone(3, RED); Stone redFour = new Stone(4, RED); - StoneSet oldSet3 = new StoneSet( - Arrays.asList(redTwo, redThree, redFour)); + StoneSet oldSet3 = new StoneSet(Arrays.asList(redTwo, redThree, redFour)); ITable newTable2 = (Table) oldTable.clone(); newTable2.drop(oldSet3, new Position(0, 0)); newSets = RoundControl.tableSetDifference(oldTable, newTable2); @@ -817,20 +797,19 @@ public class RoundControlTest { } testRoundState.players.get(0).laidOut = true; - testRoundState.players.get(0).hand.drop(new Stone(1, RED), - new Position(0, 0)); - testRoundState.players.get(0).hand.drop(new Stone(2, RED), - new Position(0, 0)); - testRoundState.players.get(1).laidOut = true; - testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, + testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0, 0)); + testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0, + 0)); + testRoundState.players.get(1).laidOut = true; + testRoundState.players.get(1).hand.drop(new Stone(RED), new Position(0, 0)); testRoundState.players.get(2).laidOut = false; - testRoundState.players.get(2).hand.drop(new Stone(9, RED), - new Position(0, 0)); - testRoundState.players.get(2).hand.drop(new Stone(10, RED), - new Position(0, 0)); - testRoundState.players.get(2).hand.drop(new Stone(11, RED), - new Position(0, 0)); + testRoundState.players.get(2).hand.drop(new Stone(9, RED), new Position(0, + 0)); + testRoundState.players.get(2).hand.drop(new Stone(10, RED), new Position(0, + 0)); + testRoundState.players.get(2).hand.drop(new Stone(11, RED), new Position(0, + 0)); testRoundState.players.get(3).laidOut = true; testRound.endOfRound(); @@ -864,19 +843,19 @@ public class RoundControlTest { } testRoundState.players.get(0).laidOut = true; - testRoundState.players.get(0).hand.drop(new Stone(1, RED), - new Position(0, 0)); - testRoundState.players.get(0).hand.drop(new Stone(2, RED), - new Position(0, 0)); + testRoundState.players.get(0).hand.drop(new Stone(1, RED), new Position(0, + 0)); + testRoundState.players.get(0).hand.drop(new Stone(2, RED), new Position(0, + 0)); testRoundState.players.get(1).laidOut = true; - testRoundState.players.get(1).hand.drop(new Stone(3, RED), - new Position(0, 0)); + testRoundState.players.get(1).hand.drop(new Stone(3, RED), new Position(0, + 0)); testRoundState.players.get(2).laidOut = true; - testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), - new Position(0, 0)); + testRoundState.players.get(2).hand.drop(new Stone(3, BLUE), new Position(0, + 0)); testRoundState.players.get(3).laidOut = false; - testRoundState.players.get(3).hand.drop(new Stone(13, RED), - new Position(0, 0)); + testRoundState.players.get(3).hand.drop(new Stone(13, RED), new Position(0, + 0)); testRound.endOfRound(); assertTrue(roundEnded); @@ -885,13 +864,13 @@ public class RoundControlTest { assertTrue(roundScore.getWinners().get(1)); assertTrue(roundScore.getWinners().get(2)); assertFalse(roundScore.getWinners().get(3)); - + assertEquals(-3, (int) roundScore.getPoints().get(0)); assertEquals(-3, (int) roundScore.getPoints().get(1)); assertEquals(-3, (int) roundScore.getPoints().get(2)); assertEquals(-100, (int) roundScore.getPoints().get(3)); } - + /** */ @Test public void testInspectOnly() { |