From cb3f9cc011c29e713c14bee92c6bacbc3dbbf379 Mon Sep 17 00:00:00 2001 From: Ida Massow Date: Wed, 18 May 2011 22:47:56 +0200 Subject: [PATCH] =?UTF-8?q?Alle=20Test=20f=C3=BCr=20Auslegen=20fertig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@255 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/RoundControlTest.java | 127 ++++++++++++++----- 1 file changed, 96 insertions(+), 31 deletions(-) diff --git a/test/jrummikub/control/RoundControlTest.java b/test/jrummikub/control/RoundControlTest.java index 735c631..e320d35 100644 --- a/test/jrummikub/control/RoundControlTest.java +++ b/test/jrummikub/control/RoundControlTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -104,14 +103,16 @@ public class RoundControlTest { /** */ @Test public void laidOutValidTooFew() { + + RoundState roundState = new RoundState(null); + RoundControl roundControl = new RoundControl(roundState, view); + roundControl.startRound(); + IHand hand = roundState.getActivePlayer().getHand(); + Stone blueOne = new Stone(1, BLUE); Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); - RoundState roundState = new RoundState(); - RoundControl roundControl = new RoundControl(roundState, view); - - 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)); @@ -126,11 +127,19 @@ public class RoundControlTest { new StoneSet(Arrays.asList(blueOne, blueTwo, blueThree)), new Position(0, 0)); + view.playerPanel.endTurnEvent.emit(); + assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); } /** */ @Test public void laidOutInvalidEnough() { + RoundState roundState = new RoundState(null); + RoundControl roundControl = new RoundControl(roundState, view); + roundControl.startRound(); + IHand hand = roundState.getActivePlayer().getHand(); + Stone blueOne = new Stone(1, BLUE); Stone blueTwo = new Stone(2, BLUE); Stone blueThree = new Stone(3, BLUE); @@ -141,10 +150,6 @@ public class RoundControlTest { Stone orangeOne = new Stone(1, ORANGE); - RoundState roundState = new RoundState(); - RoundControl roundControl = new RoundControl(roundState, view); - - 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)); @@ -154,35 +159,43 @@ public class RoundControlTest { hand.drop(redTen, new Position(0, 0)); hand.drop(orangeOne, new Position(0, 0)); - } - /** */ - @Test - public void laidOutEnoughChangedTable() { - Stone redEight = new Stone(8, RED); - Stone redNine = new Stone(9, RED); - Stone redTen = new Stone(10, RED); + hand.pickUp(orangeOne); + hand.pickUp(blueTwo); + hand.pickUp(blueThree); - Stone blueSeven = new Stone(7, BLUE); - Stone blackSeven = new Stone(7, BLACK); - Stone redSeven = new Stone(7, RED); - Stone orangeSeven = new Stone(7, ORANGE); + roundState.getTable().drop( + new StoneSet(Arrays.asList(orangeOne, blueTwo, blueThree)), + new Position(0, 0)); - StoneSet sevenSet = new StoneSet(Arrays.asList(blueSeven, blackSeven, - redSeven, orangeSeven)); + hand.pickUp(redEight); + hand.pickUp(redNine); + hand.pickUp(redTen); - RoundState roundState = new RoundState(); - RoundControl roundControl = new RoundControl(roundState, view); + roundState.getTable().drop( + new StoneSet(Arrays.asList(redEight, redNine, redTen)), + new Position(0, 0)); + view.playerPanel.endTurnEvent.emit(); + assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); } /** */ @Test public void laidOutTooFewChangedTable() { + RoundState roundState = new RoundState(null); + RoundControl roundControl = new RoundControl(roundState, view); + roundControl.startRound(); + IHand hand = roundState.getActivePlayer().getHand(); + 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.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); @@ -192,14 +205,70 @@ public class RoundControlTest { StoneSet sevenSet = new StoneSet(Arrays.asList(blueSeven, blackSeven, redSeven, orangeSeven)); - RoundState roundState = new RoundState(); - RoundControl roundControl = new RoundControl(roundState, view); + roundState.getTable().drop(sevenSet, new Position(0, 0)); + hand.pickUp(redEight); + hand.pickUp(redNine); + hand.pickUp(redTen); + roundState.getTable().pickUpStone(redSeven); + roundState.getTable() + .drop(new StoneSet(Arrays.asList(redSeven, redEight, redNine, + redTen)), new Position(0, 0)); + + view.playerPanel.endTurnEvent.emit(); + assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); + } + + /** */ + @Test + public void laidOutEnoughChangedTable() { + RoundState roundState = new RoundState(null); + RoundControl roundControl = new RoundControl(roundState, view); + roundControl.startRound(); + IHand hand = roundState.getActivePlayer().getHand(); + + 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.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)); + + hand.pickUp(redEight); + hand.pickUp(redNine); + hand.pickUp(redTen); + hand.pickUp(redEleven); + roundState.getTable().pickUpStone(redSeven); + + roundState.getTable().drop( + new StoneSet(Arrays.asList(redSeven, redEight, redNine, redTen, + redEleven)), new Position(0, 0)); + + view.playerPanel.endTurnEvent.emit(); + assertTrue(roundState.getNthNextPlayer(roundState.getPlayerCount() - 1) + .getLaidOut()); } /** */ @Test public void laidOutValid() { + RoundState roundState = new RoundState(null); + RoundControl roundControl = new RoundControl(roundState, view); + roundControl.startRound(); + IHand hand = roundState.getActivePlayer().getHand(); Stone blueOne = new Stone(1, BLUE); Stone blueTwo = new Stone(2, BLUE); @@ -209,10 +278,6 @@ public class RoundControlTest { Stone redNine = new Stone(9, RED); Stone redTen = new Stone(10, RED); - RoundState roundState = new RoundState(); - RoundControl roundControl = new RoundControl(roundState, view); - - 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));