@Test public void testHealingItem_HighHealth_Server() { Statistics vals = new Statistics(); vals = vals.copy("HP", 20); vals = vals.copy("Mov", 5); vals = vals.copy("Con", 8); Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals); unit.addToInventory(new HealingItem("Blarg", 15, 0, 1)); unit.setHp(15); Object result = new UseCommand(0).applyServer(null, unit); assertEquals(20, unit.getHp()); assertEquals(2, unit.getInventory().get(0).getUses()); assertEquals(null, result); }
@Test public void testRise_Server() { Statistics vals = new Statistics(); vals = vals.copy("HP", 20); vals = vals.copy("Mov", 5); vals = vals.copy("Con", 8); Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals); unit.addToInventory(new RiseTome()); unit.setHp(3); try { new UseCommand(0).applyServer(null, unit); fail("No exception thrown"); } catch (IllegalStateException e) { // success } }
@Test public void testHealingItem_OneUseWithWeapons_Server() { Statistics vals = new Statistics(); vals = vals.copy("HP", 20); vals = vals.copy("Mov", 5); vals = vals.copy("Con", 8); Unit unit = new Unit("test", Class.createClass("Ike"), '-', vals, vals); unit.addToInventory(new HealingItem("Blarg", 15, 0, 1)); unit.setHp(15); unit.getInventory().get(0).setUsesDEBUGGING(1); unit.addToInventory(createAxe(1)); unit.addToInventory(createAxe(2)); unit.addToInventory(createAxe(3)); // assert doesn't throw anything Object result = new UseCommand(0).applyServer(null, unit); assertEquals(null, result); }