diff options
-rw-r--r-- | src/jrummikub/control/TurnControl.java | 14 | ||||
-rw-r--r-- | test/jrummikub/control/TurnControlTest.java | 11 | ||||
-rw-r--r-- | test/jrummikub/model/TableTest.java | 56 |
3 files changed, 56 insertions, 25 deletions
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java index 7616e14..a71e56c 100644 --- a/src/jrummikub/control/TurnControl.java +++ b/src/jrummikub/control/TurnControl.java @@ -5,7 +5,9 @@ import java.util.List; import jrummikub.model.IHand; import jrummikub.model.ITable; +import jrummikub.model.Position; import jrummikub.model.Stone; +import jrummikub.model.StoneSet; import jrummikub.util.Connection; import jrummikub.util.Event; import jrummikub.util.IEvent; @@ -107,6 +109,18 @@ public class TurnControl { view.setSelectedStones(selectedStones); } + + private void leftConnectorClick(StoneSet set){ + + } + + private void rightConnectorClick(StoneSet set){ + + } + + private void tableClick(Position position){ + + } private void endOfTurn() { timer.stopTimer(); diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 7edc921..9617233 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -1,10 +1,15 @@ package jrummikub.control; -import static org.junit.Assert.*; +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.assertSame; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; import jrummikub.model.MockHand; @@ -23,8 +28,6 @@ import jrummikub.view.MockView; import org.junit.Before; import org.junit.Test; -import static jrummikub.model.StoneColor.*; - public class TurnControlTest { static class AccessibleTable extends Table{ StoneSet[] getSetArray(){ diff --git a/test/jrummikub/model/TableTest.java b/test/jrummikub/model/TableTest.java index 36d2a22..44605e2 100644 --- a/test/jrummikub/model/TableTest.java +++ b/test/jrummikub/model/TableTest.java @@ -14,70 +14,84 @@ import org.junit.Test; public class TableTest { Table testTable; - + @Before public void setup() { testTable = new Table(); } - + @Test public void testIsValid() { - testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK), - new Stone(1, BLACK))), new Position(0,0)); - testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), new Stone(2, RED), - new Stone(3, RED))), new Position(0,0)); + testTable.drop( + new StoneSet(Arrays.asList(new Stone(RED), new Stone(BLACK), + new Stone(1, BLACK))), new Position(0, 0)); + testTable.drop( + new StoneSet(Arrays.asList(new Stone(1, RED), + new Stone(2, RED), new Stone(3, RED))), new Position(0, + 0)); assertTrue(testTable.isValid()); - testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))), new Position(0,0)); + testTable.drop(new StoneSet(Arrays.asList(new Stone(5, RED))), + new Position(0, 0)); assertFalse(testTable.isValid()); } - + @Test public void testEmptyIsValid() { assertTrue(testTable.isValid()); } - + @Test @SuppressWarnings("unused") public void testPickUpStoneGroup() { Stone targetStone = new Stone(BLACK); - testTable.drop(new StoneSet(Arrays.asList(new Stone(RED), targetStone, - new Stone(1, BLACK))), new Position(0,0)); + testTable.drop( + new StoneSet(Arrays.asList(new Stone(RED), targetStone, + new Stone(1, BLACK))), new Position(0, 0)); assertTrue(testTable.isValid()); testTable.pickUpStone(targetStone); assertFalse(testTable.isValid()); - + int counter = 0; for (Object i : testTable) { counter++; } assertEquals(1, counter); } - + + @Test + public void testPickLonelyStone() { + Stone targetStone = new Stone(BLACK); + testTable.drop(new StoneSet(targetStone), new Position(0, 0)); + testTable.pickUpStone(targetStone); + assertEquals(0, testTable.getSize()); + } + @Test @SuppressWarnings("unused") public void testPickUpStoneRun() { Stone targetStone = new Stone(BLACK); - testTable.drop(new StoneSet(Arrays.asList(new Stone(1, RED), targetStone, - new Stone(3, RED))), new Position(0,0)); + testTable.drop( + new StoneSet(Arrays.asList(new Stone(1, RED), targetStone, + new Stone(3, RED))), new Position(0, 0)); assertTrue(testTable.isValid()); testTable.pickUpStone(targetStone); assertFalse(testTable.isValid()); - + int counter = 0; for (Object i : testTable) { counter++; } assertEquals(2, counter); } - + @Test public void testFindSet() { Stone targetStone = new Stone(BLACK); - StoneSet testSet = new StoneSet(Arrays.asList(new Stone(1, RED), targetStone, - new Stone(3, RED))); - testTable.drop(testSet, new Position(0,0)); - + StoneSet testSet = new StoneSet(Arrays.asList(new Stone(1, RED), + targetStone, new Stone(3, RED))); + testTable.drop(testSet, new Position(0, 0)); + StoneSet foundSet = testTable.findStoneSet(targetStone); assertSame(testSet, foundSet); } |