Exemplo n.º 1
0
  /**
   * {@link ChassisOmniMech#getFixedMass()} shall return the mass of the chassis with all non fixed
   * items and armor removed.
   */
  @Test
  public final void testGetFixedHeatSinks() {
    ChassisOmniMech cut = makeDefaultCUT();

    List<Item> fixed1 = new ArrayList<>();
    List<Item> fixed2 = new ArrayList<>();
    List<Item> fixed3 = new ArrayList<>();

    Item item1 = Mockito.mock(Item.class);
    HeatSink hs1 = Mockito.mock(HeatSink.class);
    HeatSink hs2 = Mockito.mock(HeatSink.class);

    Mockito.when(item1.getMass()).thenReturn(1.0);
    Mockito.when(hs1.getMass()).thenReturn(2.0);
    Mockito.when(hs2.getMass()).thenReturn(3.0);

    fixed1.add(item1);
    fixed1.add(hs1);
    fixed2.add(hs1);
    fixed2.add(hs1);
    fixed3.add(hs2);

    Mockito.when(components[2].getFixedItems()).thenReturn(fixed1);
    Mockito.when(components[3].getFixedItems()).thenReturn(fixed2);
    Mockito.when(components[5].getFixedItems()).thenReturn(fixed3);

    assertEquals(4, cut.getFixedHeatSinks());
  }
Exemplo n.º 2
0
  @Test
  public final void testIsAllowed_NoComponentSupport() {
    Item item = Mockito.mock(Item.class);
    Mockito.when(item.getHardpointType()).thenReturn(HardPointType.NONE);
    Mockito.when(item.getFaction()).thenReturn(Faction.Clan);
    Mockito.when(item.isCompatible(Matchers.any(Upgrades.class))).thenReturn(true);

    ChassisOmniMech cut = makeDefaultCUT();
    assertTrue(cut.isAllowed(item)); // Item in it self is allowed

    // But no component supports it.
    for (Location location : Location.values()) {
      Mockito.when(components[location.ordinal()].isAllowed(item, null)).thenReturn(false);
    }
    assertFalse(cut.isAllowed(item));
  }
Exemplo n.º 3
0
  /**
   * {@link ChassisOmniMech#getFixedMass()} shall return the mass of the chassis with all non fixed
   * items and armor removed.
   */
  @Test
  public final void testGetFixedMass() {
    ChassisOmniMech cut = makeDefaultCUT();

    List<Item> fixed1 = new ArrayList<>();
    List<Item> fixed2 = new ArrayList<>();
    List<Item> fixed3 = new ArrayList<>();

    Item item1 = Mockito.mock(Item.class);
    Item item2 = Mockito.mock(Item.class);
    Item item3 = Mockito.mock(Item.class);

    Mockito.when(item1.getMass()).thenReturn(1.0);
    Mockito.when(item2.getMass()).thenReturn(2.0);
    Mockito.when(item3.getMass()).thenReturn(3.0);

    fixed1.add(item1);
    fixed1.add(item2);
    fixed2.add(item2);
    fixed2.add(item2);
    fixed3.add(item3);

    Mockito.when(components[2].getFixedItems()).thenReturn(fixed1);
    Mockito.when(components[3].getFixedItems()).thenReturn(fixed2);
    Mockito.when(components[5].getFixedItems()).thenReturn(fixed3);

    Mockito.when(structureType.getStructureMass(cut)).thenReturn(3.0);

    double expected = 1 * 1 + 3 * 2 + 1 * 3 + 3;

    assertEquals(expected, cut.getFixedMass(), 0.0);

    Mockito.verify(armorType, Mockito.never()).getArmorMass(Matchers.anyInt());
  }