From: Kimmo R. <ki...@us...> - 2012-07-16 22:36:31
|
Update of /cvsroot/arianne/stendhal/tests/games/stendhal/server/actions In directory vz-cvs-4.sog:/tmp/cvs-serv7986/tests/games/stendhal/server/actions Modified Files: CommandCenterTest.java Log Message: Suggest close matches for misstyped commands. Feature request [3148233] Index: CommandCenterTest.java =================================================================== RCS file: /cvsroot/arianne/stendhal/tests/games/stendhal/server/actions/CommandCenterTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CommandCenterTest.java 5 Dec 2010 13:40:41 -0000 1.15 --- CommandCenterTest.java 16 Jul 2012 22:36:29 -0000 1.16 *************** *** 87,96 **** public void testExecuteUnknown() { final RPAction action = new RPAction(); action.put("type", ""); final Player caster = PlayerTestHelper.createPlayer("bob"); CommandCenter.execute(caster, action); ! assertEquals("Unknown command . Please type /help to get a list.", caster.events().get(0).get("text")); } - } --- 87,125 ---- public void testExecuteUnknown() { final RPAction action = new RPAction(); + + CommandCenter.register("this", new ActionListener() { + public void onAction(final Player player, final RPAction action) { + } + }); + CommandCenter.register("that", new ActionListener() { + public void onAction(final Player player, final RPAction action) { + + } + }); + CommandCenter.register("thus", new ActionListener() { + public void onAction(final Player player, final RPAction action) { + } + }); + action.put("type", ""); final Player caster = PlayerTestHelper.createPlayer("bob"); CommandCenter.execute(caster, action); ! assertEquals("Unknown command ''. Please type #/help to get a list.", caster.events().get(0).get("text")); ! caster.clearEvents(); ! ! action.put("type", "taat"); ! CommandCenter.execute(caster, action); ! assertEquals("Unknown command 'taat'. Did you mean #'that'? Or type #/help to get a list.", caster.events().get(0).get("text")); ! caster.clearEvents(); ! ! action.put("type", "thos"); ! CommandCenter.execute(caster, action); ! assertEquals("Unknown command 'thos'. Did you mean #'this' or #'thus'? Or type #/help to get a list.", caster.events().get(0).get("text")); ! caster.clearEvents(); ! ! action.put("type", "thas"); ! CommandCenter.execute(caster, action); ! assertEquals("Unknown command 'thas'. Did you mean #'that', #'this' or #'thus'? Or type #/help to get a list.", caster.events().get(0).get("text")); } } |