public void testCreatesItemMenuWithItemsCorrectly() { _player.addItem(Item.BLOCKABALL); _player.addItem(Item.HEALVIAL); JMenu menu = _constructor.createItemMenu(); assertNameAndText(menu, "Items", "Items"); assertEquals("Number of menus was not correct", 3, menu.getItemCount()); assertAllItemsHaveNames(menu); JMenuItem blockaballItemMenu = getWithName(menu, "BLOCKABALL"); assertNotNull("Blockaball item menu was not added", blockaballItemMenu); assertEquals("Blockaball text was not right", "Blockaball", blockaballItemMenu.getText()); assertNotNull("Blockaball action was not set", blockaballItemMenu.getAction()); assertEquals(ItemAction.class, blockaballItemMenu.getAction().getClass()); JMenuItem healVialItemMenu = getWithName(menu, "HEALVIAL"); assertNotNull("HealVial item menu was not added", healVialItemMenu); assertEquals("HealVial text was not right", "Heal Vial", healVialItemMenu.getText()); assertNotNull("HealVial action was not set", healVialItemMenu.getAction()); assertEquals(ItemAction.class, healVialItemMenu.getAction().getClass()); JMenuItem backItemMenu = getWithName(menu, "Back"); assertNotNull("Back item menu was not added", backItemMenu); assertEquals("Back item text was not right", "Back", backItemMenu.getText()); assertNotNull("Back action was not set", backItemMenu.getAction()); assertEquals(BackAction.class, backItemMenu.getAction().getClass()); }
public void testCreatesItemMenuWithNoItemsCorrectly() { JMenu menu = _constructor.createItemMenu(); assertNameAndText(menu, "Items", "Items"); assertEquals("Number of menus was not correct", 1, menu.getItemCount()); JMenuItem backButton = menu.getItem(0); assertNameAndText(backButton, "Back", "Back"); assertNotNull("Back button was not added", backButton); assertNotNull("Back button action was not set", backButton.getAction()); assertEquals(BackAction.class, backButton.getAction().getClass()); }