diff options
3 files changed, 58 insertions, 9 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java index e2eea05..b722b68 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEvent.java | |||
@@ -56,7 +56,7 @@ public final class ImmutableEvent | |||
56 | 56 | ||
57 | public List<Direction> getLegalMoves() | 57 | public List<Direction> getLegalMoves() |
58 | { | 58 | { |
59 | return Collections.unmodifiableList(ev.getLegalMoves()); | 59 | return ev.getLegalMoves(); |
60 | } | 60 | } |
61 | 61 | ||
62 | public int getAnimationStep() | 62 | public int getAnimationStep() |
diff --git a/test/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEventTest.java b/test/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEventTest.java new file mode 100644 index 0000000..31e52a0 --- /dev/null +++ b/test/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEventTest.java | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * To change this template, choose Tools | Templates | ||
3 | * and open the template in the editor. | ||
4 | */ | ||
5 | |||
6 | package com.fourisland.fourpuzzle.gamestate.mapview.event; | ||
7 | |||
8 | import com.fourisland.fourpuzzle.Direction; | ||
9 | import com.fourisland.fourpuzzle.Layer; | ||
10 | import com.fourisland.fourpuzzle.gamestate.mapview.Map; | ||
11 | import java.awt.Point; | ||
12 | import java.util.ArrayList; | ||
13 | import java.util.List; | ||
14 | import org.junit.After; | ||
15 | import org.junit.AfterClass; | ||
16 | import org.junit.Before; | ||
17 | import org.junit.BeforeClass; | ||
18 | import org.junit.Test; | ||
19 | import static org.junit.Assert.*; | ||
20 | |||
21 | /** | ||
22 | * | ||
23 | * @author hatkirby | ||
24 | */ | ||
25 | public class ImmutableEventTest { | ||
26 | |||
27 | ImmutableEvent ie; | ||
28 | Event ev; | ||
29 | |||
30 | @Before | ||
31 | public void setUp() | ||
32 | { | ||
33 | LayerEvent temp = new LayerEvent(1, 2, "Test"); | ||
34 | temp.addEvent(new PossibleEvent()); | ||
35 | |||
36 | ev = temp; | ||
37 | ie = new ImmutableEvent(ev); | ||
38 | } | ||
39 | |||
40 | @Test | ||
41 | public void testLiveness() | ||
42 | { | ||
43 | // First, modify the internal event | ||
44 | ev.setAnimationStep(2); | ||
45 | ev.setDirection(Direction.East); | ||
46 | ev.setLocation(1, 3); | ||
47 | ev.setMoveSpeed(MoveSpeed.Slower2); | ||
48 | |||
49 | // Then, ensure that the immutable event reflects these changes | ||
50 | assertEquals(ie.getAnimationStep(), 2); | ||
51 | assertEquals(ie.getDirection(), Direction.East); | ||
52 | assertEquals(ie.getLocation(), new Point(1, 3)); | ||
53 | assertEquals(ie.getMoveSpeed(), MoveSpeed.Slower2); | ||
54 | } | ||
55 | |||
56 | } \ No newline at end of file | ||
diff --git a/test/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPreconditionTest.java b/test/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPreconditionTest.java index bc86459..dd8d5b5 100644 --- a/test/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPreconditionTest.java +++ b/test/com/fourisland/fourpuzzle/gamestate/mapview/event/precondition/SwitchPreconditionTest.java | |||
@@ -18,9 +18,6 @@ import static org.junit.Assert.*; | |||
18 | */ | 18 | */ |
19 | public class SwitchPreconditionTest { | 19 | public class SwitchPreconditionTest { |
20 | 20 | ||
21 | public SwitchPreconditionTest() { | ||
22 | } | ||
23 | |||
24 | String switchName = "TestSwitch"; | 21 | String switchName = "TestSwitch"; |
25 | SwitchPrecondition sp; | 22 | SwitchPrecondition sp; |
26 | 23 | ||
@@ -44,9 +41,5 @@ public class SwitchPreconditionTest { | |||
44 | Game.getSaveFile().getSwitches().put(switchName, true); | 41 | Game.getSaveFile().getSwitches().put(switchName, true); |
45 | assertTrue(sp.match()); | 42 | assertTrue(sp.match()); |
46 | } | 43 | } |
47 | 44 | ||
48 | @After | ||
49 | public void tearDown() { | ||
50 | } | ||
51 | |||
52 | } \ No newline at end of file | 45 | } \ No newline at end of file |