summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-05 15:57:13 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-05 15:57:13 +0200
commitf5075789facf8a133f1c225ca9d25a1e0a801f43 (patch)
tree3cfece368a1413ee609f60942bcbf1a48dd69da2 /test/jrummikub/control
parent433a0c3561eeaec96c23656a347e38e3a3602597 (diff)
downloadJRummikub-f5075789facf8a133f1c225ca9d25a1e0a801f43.tar
JRummikub-f5075789facf8a133f1c225ca9d25a1e0a801f43.zip
Table Difference Test gebaut, anfang Implementierung round control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@143 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/RoundControlTest.java42
1 files changed, 41 insertions, 1 deletions
diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java
index caace50..783eabe 100644
--- a/test/jrummikub/control/RoundControlTest.java
+++ b/test/jrummikub/control/RoundControlTest.java
@@ -1,5 +1,8 @@
package jrummikub.control;
+import static jrummikub.model.StoneColor.BLACK;
+import static jrummikub.model.StoneColor.BLUE;
+import static jrummikub.model.StoneColor.RED;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -7,7 +10,10 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
import jrummikub.model.MockGameState;
import jrummikub.model.MockTable;
@@ -40,7 +46,8 @@ public class RoundControlTest {
private void checkCorrectlyDealed() {
assertEquals(106 - testGameState.getPlayerCount() * 14
- - testGameState.table.getSize(), testGameState.getGameHeap().getSize());
+ - testGameState.table.getSize(), testGameState.getGameHeap()
+ .getSize());
for (int i = 0; i < testGameState.getPlayerCount(); i++) {
assertEquals(14, testGameState.getPlayer(i).getHand().getSize());
}
@@ -196,4 +203,37 @@ public class RoundControlTest {
assertTrue(view.displayWinPanel);
}
+
+ @Test
+ public void testTableDifference() {
+ MockTable oldTable = new MockTable();
+ MockTable newTable = new MockTable();
+ 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);
+ 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));
+ newTable.drop(newSet1, new Position(0, 0));
+ newTable.drop(newSet2, new Position(0, 0));
+
+ Set<Stone> expectedStones = new HashSet<Stone>();
+ expectedStones.add(blueTwo);
+ expectedStones.add(blueThree);
+ expectedStones.add(blueFour);
+
+ Set<Stone> stones = RoundControl.tableDifference(oldTable, newTable);
+
+ assertTrue(expectedStones.containsAll(stones));
+ assertTrue(stones.containsAll(expectedStones));
+ }
}