summaryrefslogtreecommitdiffstats
path: root/test/jrummikub/control
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 17:11:44 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-08 17:11:44 +0200
commit41fe3c93b3f0c880ce550fda4cd6ad6f30d3e99c (patch)
tree2447a1d2bcddc8ccd0ee864767f9aba18e59bd19 /test/jrummikub/control
parent3ff911ab930cb87f90307b9a82dafc4d0b5fe305 (diff)
downloadJRummikub-41fe3c93b3f0c880ce550fda4cd6ad6f30d3e99c.tar
JRummikub-41fe3c93b3f0c880ce550fda4cd6ad6f30d3e99c.zip
Test für util und save control
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@387 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r--test/jrummikub/control/SaveControlTest.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/jrummikub/control/SaveControlTest.java b/test/jrummikub/control/SaveControlTest.java
new file mode 100644
index 0000000..b2e0299
--- /dev/null
+++ b/test/jrummikub/control/SaveControlTest.java
@@ -0,0 +1,68 @@
+package jrummikub.control;
+
+import static jrummikub.model.StoneColor.*;
+import static org.junit.Assert.*;
+
+import java.awt.Color;
+import java.io.File;
+import java.io.IOException;
+
+import jrummikub.model.GameSettings;
+import jrummikub.model.GameState;
+import jrummikub.model.IRoundState;
+import jrummikub.model.PlayerSettings;
+import jrummikub.model.Position;
+import jrummikub.model.RoundState;
+import jrummikub.model.Stone;
+import jrummikub.model.StoneSet;
+import jrummikub.util.IListener3;
+import jrummikub.view.MockView;
+
+import org.junit.Test;
+
+public class SaveControlTest {
+ @Test
+ public void testSaveLoad() throws IOException {
+ GameSettings settings = new GameSettings();
+ settings.getPlayerList().add(new PlayerSettings("Matze", Color.GREEN));
+ settings.getPlayerList().add(new PlayerSettings("Ida", Color.PINK));
+
+ GameState gameState = new GameState();
+ RoundState roundState = new RoundState(settings);
+
+ Stone stone1 = new Stone(1, RED);
+ Stone stone2 = new Stone(5, RED);
+ Stone stone3 = new Stone(2, RED);
+
+ roundState.getTable().drop(new StoneSet(stone1), new Position(0, 0));
+ roundState.getActivePlayer().getHand().drop(stone2, new Position(0, 0));
+ roundState.getActivePlayer().getHand().drop(stone3, new Position(0, 0));
+
+ MockView view = new MockView();
+ SaveControl saveControl = new SaveControl(view);
+ saveControl.setGameSettings(settings);
+ saveControl.setGameState(gameState);
+ saveControl.setRoundState(roundState);
+
+ File file = File.createTempFile("testSave", ".rum");
+
+ view.saveEvent.emit(file);
+
+ saveControl.getLoadEvent().add(
+ new IListener3<GameSettings, GameState, IRoundState>() {
+
+ @Override
+ public void handle(GameSettings settings,
+ GameState gameState, IRoundState roundState) {
+ assertEquals(2, settings.getPlayerList().size());
+ assertEquals(1, roundState.getTable().getSize());
+ assertEquals(2, roundState.getActivePlayer().getHand()
+ .getSize());
+ }
+ });
+
+ view.loadEvent.emit(file);
+ file.delete();
+ }
+
+}