summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/jrummikub/control/RoundControlTest.java289
-rw-r--r--test/jrummikub/model/RoundStateTest.java2
2 files changed, 183 insertions, 108 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index e320d35..1e2ee89 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -20,6 +20,7 @@ import java.util.Set;
import jrummikub.model.Hand;
import jrummikub.model.IHand;
import jrummikub.model.ITable;
+import jrummikub.model.MockGameSettings;
import jrummikub.model.MockRoundState;
import jrummikub.model.MockTable;
import jrummikub.model.Position;
@@ -99,215 +100,274 @@ public class RoundControlTest {
view.displayStartTurnPanel = false;
}
+ // TODO: evt. Mock round/gaestate zwecks hargecodeter player, dann wer weiß,
+ // wie wir sonst an Player rankommen
+
// laidOut test cases
- /** */
+ /** Threshold=30 */
@Test
public void laidOutValidTooFew() {
-
- RoundState roundState = new RoundState(null);
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
RoundControl roundControl = new RoundControl(roundState, view);
roundControl.startRound();
- IHand hand = roundState.getActivePlayer().getHand();
+ view.startTurnEvent.emit();
Stone blueOne = new Stone(1, BLUE);
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
+ IHand hand = roundState.getActivePlayer().getHand();
hand.drop(blueOne, new Position(0, 0));
hand.drop(blueTwo, new Position(0, 0));
hand.drop(blueThree, new Position(0, 0));
assertFalse(roundState.getActivePlayer().getLaidOut());
- hand.pickUp(blueOne);
- hand.pickUp(blueTwo);
- hand.pickUp(blueThree);
+ view.handPanel.stoneClickEvent.emit(blueOne, false);
+ view.handPanel.stoneClickEvent.emit(blueTwo, true);
+ view.handPanel.stoneClickEvent.emit(blueThree, true);
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(blueOne, blueTwo, blueThree)),
- new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
+ assertEquals(0, roundState.getTable().getSize());
}
- /** */
+ /** Threshold=30 */
@Test
public void laidOutInvalidEnough() {
- RoundState roundState = new RoundState(null);
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
RoundControl roundControl = new RoundControl(roundState, view);
roundControl.startRound();
- IHand hand = roundState.getActivePlayer().getHand();
+ view.startTurnEvent.emit();
Stone blueOne = new Stone(1, BLUE);
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
- Stone redEight = new Stone(8, RED);
- Stone redNine = new Stone(9, RED);
- Stone redTen = new Stone(10, RED);
-
- Stone orangeOne = new Stone(1, ORANGE);
-
+ IHand hand = roundState.getActivePlayer().getHand();
hand.drop(blueOne, new Position(0, 0));
hand.drop(blueTwo, new Position(0, 0));
hand.drop(blueThree, new Position(0, 0));
- hand.drop(redEight, new Position(0, 0));
- hand.drop(redNine, new Position(0, 0));
- hand.drop(redTen, new Position(0, 0));
+ view.handPanel.stoneClickEvent.emit(blueOne, false);
+ view.handPanel.stoneClickEvent.emit(blueTwo, true);
+ view.handPanel.stoneClickEvent.emit(blueThree, true);
- hand.drop(orangeOne, new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
- hand.pickUp(orangeOne);
- hand.pickUp(blueTwo);
- hand.pickUp(blueThree);
+ Stone blueTen = new Stone(10, BLUE);
+ Stone redTen = new Stone(10, RED);
+ Stone blueEleven = new Stone(11, BLUE);
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(orangeOne, blueTwo, blueThree)),
- new Position(0, 0));
+ assertFalse(roundState.getActivePlayer().getLaidOut());
+
+ hand.drop(blueTen, new Position(0, 0));
+ hand.drop(redTen, new Position(0, 0));
+ hand.drop(blueEleven, new Position(0, 0));
- hand.pickUp(redEight);
- hand.pickUp(redNine);
- hand.pickUp(redTen);
+ view.handPanel.stoneClickEvent.emit(blueTen, false);
+ view.handPanel.stoneClickEvent.emit(redTen, true);
+ view.handPanel.stoneClickEvent.emit(blueEleven, true);
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(redEight, redNine, redTen)),
- new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
+ assertEquals(0, roundState.getTable().getSize());
}
- /** */
+ /** Threshold=30 */
@Test
public void laidOutTooFewChangedTable() {
- RoundState roundState = new RoundState(null);
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
RoundControl roundControl = new RoundControl(roundState, view);
roundControl.startRound();
+ view.startTurnEvent.emit();
+ // Fake Turn to put stones on the table
+ Stone blueSeven = new Stone(7, BLUE);
+ Stone blackSeven = new Stone(7, BLACK);
+ Stone redSeven = new Stone(7, RED);
+ Stone orangeSeven = new Stone(7, ORANGE);
+
+ Stone blueOne = new Stone(1, BLUE);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+
IHand hand = roundState.getActivePlayer().getHand();
+ hand.drop(blueOne, new Position(0, 0));
+ hand.drop(blueTwo, new Position(0, 0));
+ hand.drop(blueThree, new Position(0, 0));
+
+ hand.drop(redSeven, new Position(0, 0));
+ hand.drop(blueSeven, new Position(0, 0));
+ hand.drop(blackSeven, new Position(0, 0));
+ hand.drop(orangeSeven, new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(redSeven, false);
+ view.handPanel.stoneClickEvent.emit(blueSeven, true);
+ view.handPanel.stoneClickEvent.emit(blackSeven, true);
+ view.handPanel.stoneClickEvent.emit(orangeSeven, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(blueOne, false);
+ view.handPanel.stoneClickEvent.emit(blueTwo, true);
+ view.handPanel.stoneClickEvent.emit(blueThree, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.playerPanel.endTurnEvent.emit();
+ assertEquals(2, roundState.getTable().getSize());
+ view.startTurnEvent.emit();
Stone redEight = new Stone(8, RED);
Stone redNine = new Stone(9, RED);
Stone redTen = new Stone(10, RED);
+ hand = roundState.getActivePlayer().getHand();
hand.drop(redEight, new Position(0, 0));
hand.drop(redNine, new Position(0, 0));
hand.drop(redTen, new Position(0, 0));
- Stone blueSeven = new Stone(7, BLUE);
- Stone blackSeven = new Stone(7, BLACK);
- Stone redSeven = new Stone(7, RED);
- Stone orangeSeven = new Stone(7, ORANGE);
+ view.tablePanel.stoneClickEvent.emit(redSeven, false);
+ view.handPanel.stoneClickEvent.emit(redEight, true);
+ view.handPanel.stoneClickEvent.emit(redNine, true);
+ view.handPanel.stoneClickEvent.emit(redTen, true);
- StoneSet sevenSet = new StoneSet(Arrays.asList(blueSeven, blackSeven,
- redSeven, orangeSeven));
-
- roundState.getTable().drop(sevenSet, new Position(0, 0));
- hand.pickUp(redEight);
- hand.pickUp(redNine);
- hand.pickUp(redTen);
- roundState.getTable().pickUpStone(redSeven);
+ assertFalse(roundState.getActivePlayer().getLaidOut());
- roundState.getTable()
- .drop(new StoneSet(Arrays.asList(redSeven, redEight, redNine,
- redTen)), new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
+ assertEquals(2, roundState.getTable().getSize());
}
- /** */
+ /** Threshold=30 */
@Test
public void laidOutEnoughChangedTable() {
- RoundState roundState = new RoundState(null);
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
RoundControl roundControl = new RoundControl(roundState, view);
roundControl.startRound();
+ view.startTurnEvent.emit();
+ // Fake Turn to put stones on the table
+ Stone blueSeven = new Stone(7, BLUE);
+ Stone blackSeven = new Stone(7, BLACK);
+ Stone redSeven = new Stone(7, RED);
+ Stone orangeSeven = new Stone(7, ORANGE);
+
+ Stone blueOne = new Stone(1, BLUE);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+
IHand hand = roundState.getActivePlayer().getHand();
+ hand.drop(blueOne, new Position(0, 0));
+ hand.drop(blueTwo, new Position(0, 0));
+ hand.drop(blueThree, new Position(0, 0));
+
+ hand.drop(redSeven, new Position(0, 0));
+ hand.drop(blueSeven, new Position(0, 0));
+ hand.drop(blackSeven, new Position(0, 0));
+ hand.drop(orangeSeven, new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(redSeven, false);
+ view.handPanel.stoneClickEvent.emit(blueSeven, true);
+ view.handPanel.stoneClickEvent.emit(blackSeven, true);
+ view.handPanel.stoneClickEvent.emit(orangeSeven, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(blueOne, false);
+ view.handPanel.stoneClickEvent.emit(blueTwo, true);
+ view.handPanel.stoneClickEvent.emit(blueThree, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
+ view.playerPanel.endTurnEvent.emit();
+ assertEquals(2, roundState.getTable().getSize());
+ view.startTurnEvent.emit();
Stone redEight = new Stone(8, RED);
Stone redNine = new Stone(9, RED);
Stone redTen = new Stone(10, RED);
Stone redEleven = new Stone(11, RED);
+ hand = roundState.getActivePlayer().getHand();
hand.drop(redEight, new Position(0, 0));
hand.drop(redNine, new Position(0, 0));
hand.drop(redTen, new Position(0, 0));
hand.drop(redEleven, new Position(0, 0));
- Stone blueSeven = new Stone(7, BLUE);
- Stone blackSeven = new Stone(7, BLACK);
- Stone redSeven = new Stone(7, RED);
- Stone orangeSeven = new Stone(7, ORANGE);
-
- StoneSet sevenSet = new StoneSet(Arrays.asList(blueSeven, blackSeven,
- redSeven, orangeSeven));
- roundState.getTable().drop(sevenSet, new Position(0, 0));
+ view.tablePanel.stoneClickEvent.emit(redSeven, false);
+ view.handPanel.stoneClickEvent.emit(redEight, true);
+ view.handPanel.stoneClickEvent.emit(redNine, true);
+ view.handPanel.stoneClickEvent.emit(redTen, true);
+ view.handPanel.stoneClickEvent.emit(redEleven, true);
- hand.pickUp(redEight);
- hand.pickUp(redNine);
- hand.pickUp(redTen);
- hand.pickUp(redEleven);
- roundState.getTable().pickUpStone(redSeven);
+ assertFalse(roundState.getActivePlayer().getLaidOut());
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(redSeven, redEight, redNine, redTen,
- redEleven)), new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
- assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
- .getLaidOut());
+ assertFalse(roundState
+ .getNthNextPlayer(roundState.getPlayerCount() - 1).getLaidOut());
+ assertEquals(2, roundState.getTable().getSize());
}
- /** */
+ /** Threshold=30 */
@Test
public void laidOutValid() {
- RoundState roundState = new RoundState(null);
+ MockGameSettings gameSettings = new MockGameSettings();
+ RoundState roundState = new RoundState(gameSettings);
RoundControl roundControl = new RoundControl(roundState, view);
roundControl.startRound();
- IHand hand = roundState.getActivePlayer().getHand();
+ view.startTurnEvent.emit();
+ // Fake Turn to put stones on the table
+ Stone blueSeven = new Stone(7, BLUE);
+ Stone blackSeven = new Stone(7, BLACK);
+ Stone redSeven = new Stone(7, RED);
+ Stone orangeSeven = new Stone(7, ORANGE);
Stone blueOne = new Stone(1, BLUE);
Stone blueTwo = new Stone(2, BLUE);
Stone blueThree = new Stone(3, BLUE);
- Stone redEight = new Stone(8, RED);
- Stone redNine = new Stone(9, RED);
- Stone redTen = new Stone(10, RED);
-
+ IHand hand = roundState.getActivePlayer().getHand();
hand.drop(blueOne, new Position(0, 0));
hand.drop(blueTwo, new Position(0, 0));
hand.drop(blueThree, new Position(0, 0));
- hand.drop(redEight, new Position(0, 0));
- hand.drop(redNine, new Position(0, 0));
- hand.drop(redTen, new Position(0, 0));
-
- assertFalse(roundState.getActivePlayer().getLaidOut());
+ hand.drop(redSeven, new Position(0, 0));
+ hand.drop(blueSeven, new Position(0, 0));
+ hand.drop(blackSeven, new Position(0, 0));
+ hand.drop(orangeSeven, new Position(0, 0));
- hand.pickUp(blueOne);
- hand.pickUp(blueTwo);
- hand.pickUp(blueThree);
+ view.handPanel.stoneClickEvent.emit(redSeven, false);
+ view.handPanel.stoneClickEvent.emit(blueSeven, true);
+ view.handPanel.stoneClickEvent.emit(blackSeven, true);
+ view.handPanel.stoneClickEvent.emit(orangeSeven, true);
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(blueOne, blueTwo, blueThree)),
- new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
- hand.pickUp(redEight);
- hand.pickUp(redNine);
- hand.pickUp(redTen);
+ view.handPanel.stoneClickEvent.emit(blueOne, false);
+ view.handPanel.stoneClickEvent.emit(blueTwo, true);
+ view.handPanel.stoneClickEvent.emit(blueThree, true);
- roundState.getTable().drop(
- new StoneSet(Arrays.asList(redEight, redNine, redTen)),
- new Position(0, 0));
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
view.playerPanel.endTurnEvent.emit();
-
assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1)
.getLaidOut());
+ assertEquals(2, roundState.getTable().getSize());
}
/** */
@@ -444,12 +504,27 @@ public class RoundControlTest {
view.startTurnEvent.emit();
assertFalse(view.displayStartTurnPanel);
IHand hand = testRoundState.players.get(0).hand;
- Stone stone = hand.iterator().next().getFirst();
- hand.pickUp(stone);
- testTable.drop(new StoneSet(stone), new Position(0, 0));
+
+ Stone blueEight = new Stone(8, BLUE);
+ Stone blackEight = new Stone(8, BLACK);
+ Stone redEight = new Stone(8, RED);
+ Stone orangeEight = new Stone(8, ORANGE);
+
+ hand.drop(redEight, new Position(0, 0));
+ hand.drop(blueEight, new Position(0, 0));
+ hand.drop(blackEight, new Position(0, 0));
+ hand.drop(orangeEight, new Position(0, 0));
+
+ view.handPanel.stoneClickEvent.emit(redEight, false);
+ view.handPanel.stoneClickEvent.emit(blueEight, true);
+ view.handPanel.stoneClickEvent.emit(blackEight, true);
+ view.handPanel.stoneClickEvent.emit(orangeEight, true);
+
+ view.tablePanel.clickEvent.emit(new Position(0, 0));
+
testRoundState.players.get(0).hand = new Hand();
resetTurnStart();
- view.getPlayerPanel().endTurnEvent.emit();
+ view.playerPanel.endTurnEvent.emit();
assertTrue(view.displayWinPanel);
}
diff --git a/test/jrummikub/model/RoundStateTest.java b/test/jrummikub/model/RoundStateTest.java
index bfbe857..c71cead 100644
--- a/test/jrummikub/model/RoundStateTest.java
+++ b/test/jrummikub/model/RoundStateTest.java
@@ -11,7 +11,7 @@ import org.junit.Test;
* Test class for {@link RoundState}
*/
public class RoundStateTest {
- private GameSettings settings = new GameSettings();
+ private IGameSettings settings = new GameSettings();
private IRoundState testRound;
/** */