From: Astrid S. <ast...@us...> - 2008-10-20 13:27:47
|
Update of /cvsroot/arianne/stendhal/tests/games/stendhal/server/entity/npc/fsm In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv2272/tests/games/stendhal/server/entity/npc/fsm Modified Files: EngineTest.java Log Message: straighten if clause Index: EngineTest.java =================================================================== RCS file: /cvsroot/arianne/stendhal/tests/games/stendhal/server/entity/npc/fsm/EngineTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** EngineTest.java 14 Aug 2008 16:38:40 -0000 1.16 --- EngineTest.java 20 Oct 2008 13:27:36 -0000 1.17 *************** *** 1,5 **** --- 1,8 ---- package games.stendhal.server.entity.npc.fsm; + import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; + import static org.junit.Assert.assertThat; + import static org.junit.Assert.assertTrue; import games.stendhal.server.entity.npc.ChatAction; import games.stendhal.server.entity.npc.ChatCondition; *************** *** 7,10 **** --- 10,14 ---- import games.stendhal.server.entity.npc.parser.Sentence; import games.stendhal.server.entity.player.Player; + import marauroa.common.Log4J; import org.junit.BeforeClass; *************** *** 17,20 **** --- 21,25 ---- @BeforeClass public static void setUpBeforeClass() throws Exception { + Log4J.init(); PlayerTestHelper.generatePlayerRPClasses(); PlayerTestHelper.generateNPCRPClasses(); *************** *** 55,58 **** --- 60,148 ---- assertEquals(nextState, en.getCurrentState()); } + + @Test + public void testaddBothActionsNull() throws Exception { + final Engine en = new Engine(new SpeakerNPC("bob")); + assertTrue(en.getTransitions().isEmpty()); + en.add(0, null, null, null, 0, null, null); + assertThat(en.getTransitions().size(), is(1)); + en.add(0, null, null, null, 0, null, null); + assertThat(en.getTransitions().size(), is(1)); + } + + @Test + public void testaddExistingActionNull() throws Exception { + final Engine en = new Engine(new SpeakerNPC("bob")); + + en.add(0, null, null, null, 0, null, null); + assertThat(en.getTransitions().size(), is(1)); + en.add(0, null, null, null, 0, null, new ChatAction() { + + public void fire(final Player player, final Sentence sentence, final SpeakerNPC npc) { + + } + }); + assertThat(en.getTransitions().size(), is(2)); + + } + + @Test + public void testaddnewNullAction() throws Exception { + final Engine en = new Engine(new SpeakerNPC("bob")); + + + en.add(0, null, null, null, 0, null, new ChatAction() { + + public void fire(final Player player, final Sentence sentence, final SpeakerNPC npc) { + + } + }); + assertThat(en.getTransitions().size(), is(1)); + en.add(0, null, null, null, 0, null, null); + + assertThat(en.getTransitions().size(), is(2)); + + } + + @Test + public void testaddSameAction() throws Exception { + final Engine en = new Engine(new SpeakerNPC("bob")); + ChatAction chatAction = new ChatAction() { + + public void fire(final Player player, final Sentence sentence, final SpeakerNPC npc) { + + } + }; + en.add(0, null, null, null, 0, null, chatAction); + assertThat(en.getTransitions().size(), is(1)); + + en.add(0, null, null, null, 0, null, chatAction); + assertThat(en.getTransitions().size(), is(1)); + + } + + @Test + public void testaddNotSameAction() throws Exception { + final Engine en = new Engine(new SpeakerNPC("bob")); + ChatAction chatAction1 = new ChatAction() { + + public void fire(final Player player, final Sentence sentence, final SpeakerNPC npc) { + + } + }; + ChatAction chatAction2 = new ChatAction() { + + public void fire(final Player player, final Sentence sentence, final SpeakerNPC npc) { + + } + }; + en.add(0, null, null, null, 0, null, chatAction1); + assertThat(en.getTransitions().size(), is(1)); + + en.add(0, null, null, null, 0, null, chatAction2); + assertThat(en.getTransitions().size(), is(2)); + + } + @Test |