summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Harder <harder@informatik.uni-luebeck.de>2011-05-04 17:33:46 +0200
committerJannis Harder <harder@informatik.uni-luebeck.de>2011-05-04 17:33:46 +0200
commit3cd6dee363700133ec827ea9fdb40ae302b35459 (patch)
treeba623491d319f583e433ae00d8a3c2900feed393
parentd837354c56671472d62d5a258fd3554ba0307a2f (diff)
downloadJRummikub-3cd6dee363700133ec827ea9fdb40ae302b35459.tar
JRummikub-3cd6dee363700133ec827ea9fdb40ae302b35459.zip
Implemented first turn control tests
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@111 72836036-5685-4462-b002-a69064685172
-rw-r--r--test/jrummikub/control/TurnControlTest.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java
new file mode 100644
index 0000000..8ba7bc4
--- /dev/null
+++ b/test/jrummikub/control/TurnControlTest.java
@@ -0,0 +1,90 @@
+package jrummikub.control;
+
+import java.util.Collection;
+
+import jrummikub.model.Stone;
+import jrummikub.util.Event;
+import jrummikub.util.IEvent;
+import jrummikub.util.IListener;
+import jrummikub.view.IHandPanel;
+import jrummikub.view.IPlayerPanel;
+import jrummikub.view.ITablePanel;
+import jrummikub.view.IView;
+import jrummikub.view.MockView;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class TurnControlTest {
+
+ class MockTimer implements ITurnTimer {
+ boolean timerRunning;
+
+ @Override
+ public void startTimer() {
+ timerRunning = true;
+ }
+
+ @Override
+ public void stopTimer() {
+ timerRunning = false;
+ }
+
+ @Override
+ public IEvent getTimeRunOutEvent() {
+ return null;
+ }
+
+ }
+
+ MockView mockView;
+ MockTimer mockTimer;
+ boolean eventFired;
+
+ @Before
+ public void setUp() {
+ mockView = new MockView();
+ mockTimer = new MockTimer();
+ }
+
+ @Test
+ public void viewEndOfTurn() {
+ eventFired = false;
+ mockTimer.timerRunning = true;
+ TurnControl testControl = new TurnControl(null, null, mockView, mockTimer);
+
+ testControl.getEndOfTurnEvent().add(new IListener() {
+
+ @Override
+ public void handle() {
+ eventFired = true;
+ }
+ });
+
+ mockView.playerPanel.endTurnEvent.emit();
+
+ assertTrue(eventFired);
+ assertFalse(mockTimer.timerRunning);
+ }
+
+ @Test
+ public void timerEndOfTurn() {
+ eventFired = false;
+ mockTimer.timerRunning = true;
+ TurnControl testControl = new TurnControl(null, null, mockView, mockTimer);
+
+ testControl.getEndOfTurnEvent().add(new IListener() {
+
+ @Override
+ public void handle() {
+ eventFired = true;
+ }
+ });
+
+ mockView.playerPanel.endTurnEvent.emit();
+
+ assertTrue(eventFired);
+ assertFalse(mockTimer.timerRunning);
+ }
+}