use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method testDetectSameSelection.
@Test
public void testDetectSameSelection() {
Object source1 = new Object();
assertTrue(getFacet().isEmpty(id));
assertEquals(0, getFacet().getCount(id));
//Note: This is also an identity tests
CNAbility n1 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
CNAbility n2 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
CNAbilitySelection cnas1 = new CNAbilitySelection(n1, "English");
CNAbilitySelection cnas2 = new CNAbilitySelection(n2, "English");
assertTrue(getFacet().add(id, cnas1, source1));
assertFalse(getFacet().isEmpty(id));
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().add(id, cnas2, source1));
assertEquals(1, getFacet().getCount(id));
//LIFO
assertFalse(getFacet().remove(id, cnas2, source1));
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertTrue(getFacet().remove(id, cnas1, source1));
assertEquals(0, getFacet().getCount(id));
assertTrue(getFacet().isEmpty(id));
assertTrue(getFacet().add(id, cnas1, source1));
assertFalse(getFacet().isEmpty(id));
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().add(id, cnas2, source1));
assertEquals(1, getFacet().getCount(id));
//FIFO
//This assertFalse is the identity test, since it *actually* removes cnas2 and thus returns false
assertFalse(getFacet().remove(id, cnas1, source1));
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertTrue(getFacet().remove(id, cnas2, source1));
assertEquals(0, getFacet().getCount(id));
assertTrue(getFacet().isEmpty(id));
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CNAbilitySelectionUtilitiesTest method testDetectSameParentCategory.
@Test
public void testDetectSameParentCategory() {
CNAbility n1 = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
CNAbility n2 = CNAbilityFactory.getCNAbility(fighterfeat, Nature.NORMAL, nomult);
CNAbilitySelection cnas1 = new CNAbilitySelection(n1);
CNAbilitySelection cnas2 = new CNAbilitySelection(n2);
assertFalse(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
CNAbility virtual = CNAbilityFactory.getCNAbility(fighterfeat, Nature.VIRTUAL, nomult);
CNAbilitySelection cnas3 = new CNAbilitySelection(virtual);
assertFalse(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas3));
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CNAbilitySelectionUtilitiesTest method testDifferentNature.
@Test
public void testDifferentNature() {
CNAbility normal = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
CNAbility virtual = CNAbilityFactory.getCNAbility(feat, Nature.VIRTUAL, nomult);
CNAbilitySelection cnas1 = new CNAbilitySelection(normal);
CNAbilitySelection cnas2 = new CNAbilitySelection(virtual);
assertFalse(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class CNAbilitySelectionUtilitiesTest method testDifferentSelectionAndNature.
@Test
public void testDifferentSelectionAndNature() {
CNAbility normal = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, multyes);
CNAbility virtual = CNAbilityFactory.getCNAbility(feat, Nature.VIRTUAL, multyes);
CNAbilitySelection cnas1 = new CNAbilitySelection(normal, "English");
CNAbilitySelection cnas2 = new CNAbilitySelection(virtual, "German");
assertTrue(CNAbilitySelectionUtilities.canCoExist(cnas1, cnas2));
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method testDifferentCategory.
@Test
public void testDifferentCategory() {
Object source1 = new Object();
assertTrue(getFacet().isEmpty(id));
assertEquals(0, getFacet().getCount(id));
CNAbility nomultCNA = CNAbilityFactory.getCNAbility(feat, Nature.NORMAL, nomult);
Ability trickster = new Ability();
trickster.setName("NoMult");
trickster.setCDOMCategory(specialty);
CNAbility othernomultCNA = CNAbilityFactory.getCNAbility(specialty, Nature.NORMAL, trickster);
CNAbilitySelection cnas1 = new CNAbilitySelection(nomultCNA);
CNAbilitySelection cnas2 = new CNAbilitySelection(othernomultCNA);
assertTrue(getFacet().add(id, cnas1, source1));
assertFalse(getFacet().isEmpty(id));
assertEquals(1, getFacet().getCount(id));
assertTrue(getFacet().add(id, cnas2, source1));
assertEquals(2, getFacet().getCount(id));
assertTrue(getFacet().remove(id, cnas2, source1));
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
//Useless remove
assertFalse(getFacet().remove(id, cnas2, source1));
assertEquals(1, getFacet().getCount(id));
//Now a real remove
assertTrue(getFacet().remove(id, cnas1, source1));
assertEquals(0, getFacet().getCount(id));
assertTrue(getFacet().isEmpty(id));
//Useless remove
assertFalse(getFacet().remove(id, cnas2, source1));
}
Aggregations