summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control/RoundControlTest.java
blob: bc0bb3d01a091334c187744a31289dd8083fddea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package jrummikub.control;

import static org.junit.Assert.*;
import jrummikub.model.GameState;
import jrummikub.view.MockView;

import org.junit.Before;
import org.junit.Test;

public class RoundControlTest {
	private MockView view;
	private GameState testGameState;
	private RoundControl testRound;

	@Before
	public void setup() {
		view = new MockView();
		testGameState = new GameState();
		testRound = new RoundControl(testGameState, view);
	}

	private void checkCorrectlyDealed() {
		assertEquals(106 - testGameState.getPlayerCount() * 14, testGameState
				.getGameHeap().getSize());
		for (int i = 0; i < testGameState.getPlayerCount(); i++) {
			assertEquals(14, testGameState.getPlayer(i).getHand().getSize());
		}
	}

	@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());
	}
}