Added startRound test to RoundControlTest
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@122 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
4ae29c76c2
commit
d559e17077
2 changed files with 36 additions and 14 deletions
|
@ -4,16 +4,22 @@ import static org.junit.Assert.*;
|
||||||
import jrummikub.model.GameState;
|
import jrummikub.model.GameState;
|
||||||
import jrummikub.view.MockView;
|
import jrummikub.view.MockView;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RoundControlTest {
|
public class RoundControlTest {
|
||||||
|
private MockView view;
|
||||||
|
private GameState testGameState;
|
||||||
|
private RoundControl testRound;
|
||||||
|
|
||||||
@Test
|
@Before
|
||||||
public void testDeal() {
|
public void setup() {
|
||||||
MockView view = new MockView();
|
view = new MockView();
|
||||||
GameState testGameState = new GameState();
|
testGameState = new GameState();
|
||||||
RoundControl testRound = new RoundControl(testGameState, view);
|
testRound = new RoundControl(testGameState, view);
|
||||||
testRound.deal();
|
}
|
||||||
|
|
||||||
|
private void checkCorrectlyDealed() {
|
||||||
assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState
|
assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState
|
||||||
.getGameHeap().getSize());
|
.getGameHeap().getSize());
|
||||||
for (int i = 0; i < testGameState.getPlayerCount(); i++) {
|
for (int i = 0; i < testGameState.getPlayerCount(); i++) {
|
||||||
|
@ -21,6 +27,22 @@ public class RoundControlTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeal() {
|
||||||
|
testRound.deal();
|
||||||
|
checkCorrectlyDealed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStartRound() {
|
||||||
|
testRound.startRound();
|
||||||
|
checkCorrectlyDealed();
|
||||||
|
|
||||||
|
assertNotNull(view.currentPlayerName);
|
||||||
|
assertNotNull(view.getTablePanel().leftPlayerName);
|
||||||
|
assertNotNull(view.getTablePanel().topPlayerName);
|
||||||
|
assertNotNull(view.getTablePanel().rightPlayerName);
|
||||||
|
assertTrue(view.displayStartTurnPanel);
|
||||||
|
assertFalse(view.startTurnEvent.listeners.isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,9 @@ import jrummikub.util.IEvent2;
|
||||||
public class MockTablePanel implements ITablePanel {
|
public class MockTablePanel implements ITablePanel {
|
||||||
|
|
||||||
public MockStoneCollectionPanel stoneCollectionPanel = new MockStoneCollectionPanel();
|
public MockStoneCollectionPanel stoneCollectionPanel = new MockStoneCollectionPanel();
|
||||||
|
public String leftPlayerName;
|
||||||
|
public String topPlayerName;
|
||||||
|
public String rightPlayerName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
public IEvent2<Stone, Boolean> getStoneClickEvent() {
|
||||||
|
@ -39,20 +42,17 @@ public class MockTablePanel implements ITablePanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLeftPlayerName(String playerName) {
|
public void setLeftPlayerName(String playerName) {
|
||||||
// TODO Auto-generated method stub
|
leftPlayerName = playerName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTopPlayerName(String playerName) {
|
public void setTopPlayerName(String playerName) {
|
||||||
// TODO Auto-generated method stub
|
topPlayerName = playerName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRightPlayerName(String playerName) {
|
public void setRightPlayerName(String playerName) {
|
||||||
// TODO Auto-generated method stub
|
rightPlayerName = playerName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Reference in a new issue