summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-08 21:54:04 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-08 21:54:04 +0200
commitcfc674eb3dcf2a4d21a1db4768e6fd36250bdaaf (patch)
tree846a903b760adb9f7ef4818076c99918e91e183a
parent7b75af50e2e86580b03d821b7a2cbb6e9e8e3661 (diff)
downloadJRummikub-cfc674eb3dcf2a4d21a1db4768e6fd36250bdaaf.tar
JRummikub-cfc674eb3dcf2a4d21a1db4768e6fd36250bdaaf.zip
Tests fürs Anlegen von Steinen auf dem Tisch ferti
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@175 72836036-5685-4462-b002-a69064685172
-rw-r--r--test/jrummikub/control/TurnControlTest.java298
1 files changed, 293 insertions, 5 deletions
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java
index da8c83f..20534f0 100644
--- a/test/jrummikub/control/TurnControlTest.java
+++ b/test/jrummikub/control/TurnControlTest.java
@@ -405,17 +405,305 @@ public class TurnControlTest {
}
@Test
- public void takeLeftStone() {
-
+ public void testAddLeft() {
+ Stone blueOne = new Stone(1, BLUE);
+ Stone redOne = new Stone(1, RED);
+ Stone blackOne = new Stone(1, BLACK);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+ Stone blueFour = new Stone(4, BLUE);
+ Stone redTwo = new Stone(2, RED);
+ Stone redThree = new Stone(3, RED);
+ Stone redFour = new Stone(4, RED);
+ Stone blackTwo = new Stone(2, BLACK);
+ Stone blackThree = new Stone(3, BLACK);
+ Stone blackFour = new Stone(4, BLACK);
+ Stone blackFive = new Stone(5, BLACK);
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
+ mockTable.drop(oldSet1, new Position(0, 0));
+ mockTable.drop(oldSet2, new Position(0, 0));
+ mockHand.drop(blueThree, new Position(0, 0));
+ mockHand.drop(blueFour, new Position(0, 0));
+ mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false);
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.stoneClickEvent.emit(redThree, true);
+ mockView.tablePanel.leftConnectorClickEvent.emit(oldSet1);
+ // handcheck
+ assertEquals(1, mockHand.getSize());
+ assertSame(mockHand.stones.get(0), blueFour);
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ StoneSet newSet1, newSet2;
+ if (mockTable.sets.get(0).getFirst().size() == 3) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ assertSame(oldSet2, newSet2);
+ // setcheck
+ assertEquals(9, newSet1.size());
+ assertSame(newSet1.get(0), blueThree);
+ assertSame(newSet1.get(1), redOne);
+ assertSame(newSet1.get(2), redThree);
+ assertSame(newSet1.get(3), blueOne);
+ assertSame(newSet1.get(4), blackOne);
+ assertSame(newSet1.get(5), redTwo);
+ assertSame(newSet1.get(6), redFour);
+ assertSame(newSet1.get(7), blackTwo);
+ assertSame(newSet1.get(8), blackThree);
+
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.stoneClickEvent.emit(redThree, true);
+ mockView.tablePanel.leftConnectorClickEvent.emit(oldSet2);
+ // handcheck
+ assertEquals(1, mockHand.getSize());
+ assertSame(mockHand.stones.get(0), blueFour);
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ if (mockTable.sets.get(0).getFirst().size() == 5) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ // setcheck1
+ assertEquals(7, newSet1.size());
+ assertSame(newSet1.get(0), blueThree);
+ assertSame(newSet1.get(1), blueOne);
+ assertSame(newSet1.get(2), blackOne);
+ assertSame(newSet1.get(3), redTwo);
+ assertSame(newSet1.get(4), redFour);
+ assertSame(newSet1.get(5), blackTwo);
+ assertSame(newSet1.get(6), blackThree);
+ // setcheck2
+ assertEquals(5, newSet2.size());
+ assertSame(newSet2.get(0), redOne);
+ assertSame(newSet2.get(1), redThree);
+ assertSame(newSet2.get(2), blueTwo);
+ assertSame(newSet2.get(3), blackFour);
+ assertSame(newSet2.get(4), blackFive);
+ // versuche, links was wegzunehmen und wieder anzuhängen
+ mockView.tablePanel.stoneClickEvent.emit(redOne, false);
+ mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, true);
+ // handcheck
+ assertEquals(0, mockHand.getSize());
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ if (mockTable.sets.get(0).getFirst().size() == 6) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ // setcheck1
+ assertEquals(7, newSet1.size());
+ // setcheck2
+ assertEquals(6, newSet2.size());
+ assertSame(newSet2.get(0), redOne);
+ assertSame(newSet2.get(1), blueFour);
+ assertSame(newSet2.get(2), redThree);
+ assertSame(newSet2.get(3), blueTwo);
+ assertSame(newSet2.get(4), blackFour);
+ assertSame(newSet2.get(5), blackFive);
}
@Test
- public void takeRightStone() {
-
+ public void testAddRight() {
+ Stone blueOne = new Stone(1, BLUE);
+ Stone redOne = new Stone(1, RED);
+ Stone blackOne = new Stone(1, BLACK);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+ Stone blueFour = new Stone(4, BLUE);
+ Stone redTwo = new Stone(2, RED);
+ Stone redThree = new Stone(3, RED);
+ Stone redFour = new Stone(4, RED);
+ Stone blackTwo = new Stone(2, BLACK);
+ Stone blackThree = new Stone(3, BLACK);
+ Stone blackFour = new Stone(4, BLACK);
+ Stone blackFive = new Stone(5, BLACK);
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
+ mockTable.drop(oldSet1, new Position(0, 0));
+ mockTable.drop(oldSet2, new Position(0, 0));
+ mockHand.drop(blueThree, new Position(0, 0));
+ mockHand.drop(blueFour, new Position(0, 0));
+ mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false);
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.stoneClickEvent.emit(redThree, true);
+ mockView.tablePanel.rightConnectorClickEvent.emit(oldSet1);
+ // handcheck
+ assertEquals(1, mockHand.getSize());
+ assertSame(mockHand.stones.get(0), blueFour);
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ StoneSet newSet1, newSet2;
+ if (mockTable.sets.get(0).getFirst().size() == 3) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ assertSame(oldSet2, newSet2);
+ // setcheck
+ assertEquals(9, newSet1.size());
+ assertSame(newSet1.get(0), blueOne);
+ assertSame(newSet1.get(1), blackOne);
+ assertSame(newSet1.get(2), redTwo);
+ assertSame(newSet1.get(3), redFour);
+ assertSame(newSet1.get(4), blackTwo);
+ assertSame(newSet1.get(5), blackThree);
+ assertSame(newSet1.get(6), blueThree);
+ assertSame(newSet1.get(7), redOne);
+ assertSame(newSet1.get(8), redThree);
+
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.stoneClickEvent.emit(redThree, true);
+ mockView.tablePanel.rightConnectorClickEvent.emit(oldSet2);
+ // handcheck
+ assertEquals(1, mockHand.getSize());
+ assertSame(mockHand.stones.get(0), blueFour);
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ if (mockTable.sets.get(0).getFirst().size() == 5) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ // setcheck1
+ assertEquals(7, newSet1.size());
+ assertSame(newSet1.get(0), blueOne);
+ assertSame(newSet1.get(1), blackOne);
+ assertSame(newSet1.get(2), redTwo);
+ assertSame(newSet1.get(3), redFour);
+ assertSame(newSet1.get(4), blackTwo);
+ assertSame(newSet1.get(5), blackThree);
+ assertSame(newSet1.get(6), blueThree);
+ // setcheck2
+ assertEquals(5, newSet2.size());
+ assertSame(newSet2.get(0), blueTwo);
+ assertSame(newSet2.get(1), blackFour);
+ assertSame(newSet2.get(2), blackFive);
+ assertSame(newSet2.get(3), redOne);
+ assertSame(newSet2.get(4), redThree);
+ // versuche, rechts was wegzunehmen und wieder anzuhängen
+ mockView.tablePanel.stoneClickEvent.emit(redThree, false);
+ mockView.playerPanel.handPanel.stoneClickEvent.emit(blueFour, true);
+ // handcheck
+ assertEquals(0, mockHand.getSize());
+ // tablecheck
+ assertEquals(2, mockTable.getSize());
+ if (mockTable.sets.get(0).getFirst().size() == 6) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ newSet2 = mockTable.sets.get(1).getFirst();
+ }
+ // setcheck1
+ assertEquals(7, newSet1.size());
+ // setcheck2
+ assertEquals(6, newSet2.size());
+ assertSame(newSet2.get(0), blueTwo);
+ assertSame(newSet2.get(1), blackFour);
+ assertSame(newSet2.get(2), blackFive);
+ assertSame(newSet2.get(3), redOne);
+ assertSame(newSet2.get(4), blueFour);
+ assertSame(newSet2.get(5), redThree);
}
@Test
- public void takeMiddleStone() {
+ public void testAddNewSet() {
+ Stone blueOne = new Stone(1, BLUE);
+ Stone redOne = new Stone(1, RED);
+ Stone blackOne = new Stone(1, BLACK);
+ Stone blueTwo = new Stone(2, BLUE);
+ Stone blueThree = new Stone(3, BLUE);
+ Stone blueFour = new Stone(4, BLUE);
+ Stone redTwo = new Stone(2, RED);
+ Stone redThree = new Stone(3, RED);
+ Stone redFour = new Stone(4, RED);
+ Stone blackTwo = new Stone(2, BLACK);
+ Stone blackThree = new Stone(3, BLACK);
+ Stone blackFour = new Stone(4, BLACK);
+ Stone blackFive = new Stone(5, BLACK);
+ StoneSet oldSet1 = new StoneSet(Arrays.asList(blueOne, redOne,
+ blackOne, redTwo, redThree, redFour, blackTwo, blackThree));
+ StoneSet oldSet2 = new StoneSet(Arrays.asList(blueTwo, blackFour,
+ blackFive));
+ mockTable.drop(oldSet1, new Position(0, 0));
+ mockTable.drop(oldSet2, new Position(0, 0));
+ mockHand.drop(blueThree, new Position(0, 0));
+ mockHand.drop(blueFour, new Position(0, 0));
+ mockView.playerPanel.handPanel.stoneClickEvent.emit(blueThree, false);
+ mockView.tablePanel.stoneClickEvent.emit(redOne, true);
+ mockView.tablePanel.stoneClickEvent.emit(redThree, true);
+ mockView.tablePanel.stoneClickEvent.emit(blueTwo, true);
+ mockView.tablePanel.clickEvent.emit(new Position(0, 0));
+ // handcheck
+ assertEquals(1, mockHand.getSize());
+ assertSame(blueFour, mockHand.stones.get(0));
+ // tablecheck
+ StoneSet newSet1, newSet2, newSet3;
+ assertEquals(2, mockTable.getSize());
+ if (mockTable.sets.get(0).getFirst().size() == 2) {
+ newSet2 = mockTable.sets.get(0).getFirst();
+ if (mockTable.sets.get(1).getFirst().size() == 4) {
+ newSet3 = mockTable.sets.get(1).getFirst();
+ newSet1 = mockTable.sets.get(2).getFirst();
+ } else {
+ newSet3 = mockTable.sets.get(2).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ }
+ } else if (mockTable.sets.get(0).getFirst().size() == 4) {
+ newSet3 = mockTable.sets.get(0).getFirst();
+ if (mockTable.sets.get(1).getFirst().size() == 2) {
+ newSet2 = mockTable.sets.get(1).getFirst();
+ newSet1 = mockTable.sets.get(2).getFirst();
+ } else {
+ newSet2 = mockTable.sets.get(2).getFirst();
+ newSet1 = mockTable.sets.get(1).getFirst();
+ }
+ } else {
+ newSet1 = mockTable.sets.get(0).getFirst();
+ if (mockTable.sets.get(1).getFirst().size() == 2) {
+ newSet2 = mockTable.sets.get(1).getFirst();
+ newSet3 = mockTable.sets.get(2).getFirst();
+ } else {
+ newSet2 = mockTable.sets.get(2).getFirst();
+ newSet3 = mockTable.sets.get(1).getFirst();
+ }
+ }
+ // setcheck1
+ assertEquals(6, newSet1.size());
+ assertSame(newSet1.get(0), blueOne);
+ assertSame(newSet1.get(1), blackOne);
+ assertSame(newSet1.get(2), redTwo);
+ assertSame(newSet1.get(3), redFour);
+ assertSame(newSet1.get(4), blackTwo);
+ assertSame(newSet1.get(5), blackThree);
+ // setcheck2
+ assertEquals(2, newSet2.size());
+ assertSame(newSet2.get(0), blackFour);
+ assertSame(newSet2.get(1), blackFive);
+ // setcheck1
+ assertEquals(4, newSet3.size());
+ assertSame(newSet3.get(0), blueThree);
+ assertSame(newSet3.get(1), redOne);
+ assertSame(newSet3.get(2), redThree);
+ assertSame(newSet3.get(3), blueTwo);
}
}