diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-10 01:39:32 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-10 01:39:32 +0200 |
commit | ce982fcdaf1a15981419e7a88802bc225795e6a4 (patch) | |
tree | c473605663a262ab507cb9f02cc62f304df02266 /test/jrummikub/control | |
parent | 56b75e037ab2061d1f7462d2f71a83ca5a9353b6 (diff) | |
download | JRummikub-ce982fcdaf1a15981419e7a88802bc225795e6a4.tar JRummikub-ce982fcdaf1a15981419e7a88802bc225795e6a4.zip |
Tests for dropping on hand
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@206 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r-- | test/jrummikub/control/TurnControlTest.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 44b7729..b018182 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -11,8 +11,10 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import jrummikub.model.IHand; import jrummikub.model.ITable; @@ -1026,4 +1028,63 @@ public class TurnControlTest { checkHandDisplay(mockHand); } + + @Test + public void testDropHandValid() { + testControl.startTurn(); + + Stone firstStone = new Stone(StoneColor.RED); + Stone secondStone = new Stone(StoneColor.BLACK); + + mockHand.drop(firstStone, new Position(0,0)); + mockHand.drop(secondStone, new Position(1,0)); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + + mockView.playerPanel.handPanel.clickEvent.emit(new Position(2,0.25f)); + + assertCollection(new ArrayList<Stone>()); + + Set<Stone> expected = new HashSet<Stone>(Arrays.asList(firstStone, secondStone)); + assertEquals(expected, mockHand.pickups); + + Set<Stone> handStones = new HashSet<Stone>(); + for (Pair<Stone, Position> stone : mockHand.stones) { + assertEquals(stone.getSecond(), new Position(2,0)); + handStones.add(stone.getFirst()); + } + assertEquals(expected, handStones); + } + + @Test + public void testDropHandInvalid() { + testControl.startTurn(); + + Stone firstStone = new Stone(StoneColor.RED); + Stone secondStone = new Stone(StoneColor.BLACK); + Stone thirdStone = new Stone(13, StoneColor.BLACK); + + mockHand.drop(firstStone, new Position(0,0)); + mockHand.drop(thirdStone, new Position(1,0)); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.tablePanel.stoneClickEvent.emit(secondStone, true); + mockView.playerPanel.handPanel.stoneClickEvent.emit(thirdStone, true); + + mockView.playerPanel.handPanel.clickEvent.emit(new Position(2,0.25f)); + + assertCollection(Arrays.asList(secondStone)); + + Set<Stone> expected = new HashSet<Stone>(Arrays.asList(firstStone, thirdStone)); + assertEquals(expected, mockHand.pickups); + + Set<Stone> handStones = new HashSet<Stone>(); + for (Pair<Stone, Position> stone : mockHand.stones) { + assertEquals(stone.getSecond(), new Position(2,0)); + handStones.add(stone.getFirst()); + } + assertEquals(expected, handStones); + } + } |