コード例 #1
0
  public void testCreatesTheItemShopMenu() {
    ItemShop building = new ItemShop();
    building.stockItems(Item.BLOCKABALL, Item.HEALVIAL);
    JMenu menu = _constructor.createBuildingMenu(building, null);

    Assert.assertNotNull(menu);
    Assert.assertEquals(building.getName(), menu.getName());
    Assert.assertEquals(building.getName(), menu.getText());
    Assert.assertEquals(2, menu.getItemCount());
    for (int i = 0; i < menu.getItemCount(); i++) {
      JMenuItem menuItem = menu.getItem(i);
      Action action = menuItem.getAction();
      Assert.assertNotNull(action);
      Assert.assertEquals(ItemAction.class, action.getClass());

      String name = menuItem.getName();
      if (name.equals(Item.BLOCKABALL.toString())) {
        Assert.assertEquals(Item.BLOCKABALL.getWellFormattedString(), menuItem.getText());
      } else if (name.equals(Item.HEALVIAL.toString())) {
        Assert.assertEquals(Item.HEALVIAL.getWellFormattedString(), menuItem.getText());
      } else {
        Assert.fail("Name: " + name + " Text: " + menuItem.getText());
      }
    }
  }
コード例 #2
0
  public void testCreatesOutOfBattleMenu() {
    JMenu menu = _constructor.createOutOfBattleMenu();

    assertNameAndText(menu, "OutOfBattle", "Actions");

    Assert.assertEquals(5, menu.getItemCount());

    assertNameAndText(menu.getItem(0), "Blockamon", "Blockamon");
    assertNameAndText(menu.getItem(1), "Bag", "Bag");
    assertNameAndText(menu.getItem(2), "Money", "Money");
    JMenuItem saveMenuItem = menu.getItem(3);
    Action saveMenuAction = saveMenuItem.getAction();
    Assert.assertNotNull(saveMenuAction);
    Assert.assertEquals(saveMenuAction.getClass(), SaveAction.class);
    assertNameAndText(saveMenuItem, "Save", "Save");
    assertNameAndText(menu.getItem(4), "Load", "Load");
  }
コード例 #3
0
  public void testCreatesTheHealingCenterMenu() {
    Building building = new HealingCenter();
    JMenu menu = _constructor.createBuildingMenu(building, null);

    Assert.assertNotNull(menu);
    Assert.assertEquals(building.getName(), menu.getName());
    Assert.assertEquals(building.getName(), menu.getText());
    Assert.assertEquals(1, menu.getItemCount());
    for (int i = 0; i < menu.getItemCount(); i++) {
      JMenuItem menuItem = menu.getItem(i);
      Action action = menuItem.getAction();
      Assert.assertNotNull(action);
      Assert.assertEquals(HealAction.class, action.getClass());

      Assert.assertEquals("Heal", menuItem.getName());
      Assert.assertEquals("Heal", menuItem.getText());
    }
  }