From 0ebc2f2c92e4b51069f497aca9f715198010bdf2 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Wed, 18 Mar 2009 09:16:22 -0400 Subject: Engine: Added ImmutableEventTest --- .../mapview/event/ImmutableEventTest.java | 56 ++++++++++++++++++++++ .../event/precondition/SwitchPreconditionTest.java | 9 +--- 2 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 test/com/fourisland/fourpuzzle/gamestate/mapview/event/ImmutableEventTest.java (limited to 'test') 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 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.fourisland.fourpuzzle.gamestate.mapview.event; + +import com.fourisland.fourpuzzle.Direction; +import com.fourisland.fourpuzzle.Layer; +import com.fourisland.fourpuzzle.gamestate.mapview.Map; +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author hatkirby + */ +public class ImmutableEventTest { + + ImmutableEvent ie; + Event ev; + + @Before + public void setUp() + { + LayerEvent temp = new LayerEvent(1, 2, "Test"); + temp.addEvent(new PossibleEvent()); + + ev = temp; + ie = new ImmutableEvent(ev); + } + + @Test + public void testLiveness() + { + // First, modify the internal event + ev.setAnimationStep(2); + ev.setDirection(Direction.East); + ev.setLocation(1, 3); + ev.setMoveSpeed(MoveSpeed.Slower2); + + // Then, ensure that the immutable event reflects these changes + assertEquals(ie.getAnimationStep(), 2); + assertEquals(ie.getDirection(), Direction.East); + assertEquals(ie.getLocation(), new Point(1, 3)); + assertEquals(ie.getMoveSpeed(), MoveSpeed.Slower2); + } + +} \ 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.*; */ public class SwitchPreconditionTest { - public SwitchPreconditionTest() { - } - String switchName = "TestSwitch"; SwitchPrecondition sp; @@ -44,9 +41,5 @@ public class SwitchPreconditionTest { Game.getSaveFile().getSwitches().put(switchName, true); assertTrue(sp.match()); } - - @After - public void tearDown() { - } - + } \ No newline at end of file -- cgit 1.4.1