use of pcgen.cdom.helper.CNAbilitySelection 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.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method testTypeAddUselessRemove.
@Test
public void testTypeAddUselessRemove() {
Object source1 = new Object();
CNAbilitySelection t1 = getMultObject("English");
getFacet().add(id, t1, source1);
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertNotNull(getFacet().getSet(id));
assertEquals(1, getFacet().getSet(id).size());
assertEquals(t1, getFacet().getSet(id).iterator().next());
assertEventCount(1, 0);
// Useless Remove
getFacet().remove(id, getMultObject("German"), source1);
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertNotNull(getFacet().getSet(id));
assertEquals(1, getFacet().getSet(id).size());
assertEquals(t1, getFacet().getSet(id).iterator().next());
assertEventCount(1, 0);
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method testTypeAddMultGet.
@Test
public void testTypeAddMultGet() {
Object source1 = new Object();
CNAbilitySelection t1 = getMultObject("English");
getFacet().add(id, t1, source1);
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
Collection<CNAbilitySelection> setofone = getFacet().getSet(id);
assertNotNull(setofone);
assertEquals(1, setofone.size());
assertEquals(t1, setofone.iterator().next());
assertEventCount(1, 0);
CNAbilitySelection t2 = getMultObject("German");
getFacet().add(id, t2, source1);
assertEquals(2, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
Collection<CNAbilitySelection> setoftwo = getFacet().getSet(id);
assertNotNull(setoftwo);
assertEquals(2, setoftwo.size());
assertTrue(setoftwo.contains(t1));
assertTrue(setoftwo.contains(t2));
assertEventCount(2, 0);
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbstractCNASEnforcingFacetTest method testTypeAddSingleTwiceTwoSourceGet.
@Test
public void testTypeAddSingleTwiceTwoSourceGet() {
Object source1 = new Object();
Object source2 = new Object();
CNAbilitySelection t1 = getObject();
getFacet().add(id, t1, source1);
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertNotNull(getFacet().getSet(id));
assertEquals(1, getFacet().getSet(id).size());
assertEquals(t1, getFacet().getSet(id).iterator().next());
assertEventCount(1, 0);
// Add same, still only once in set (and only one event)
getFacet().add(id, t1, source2);
assertEquals(1, getFacet().getCount(id));
assertFalse(getFacet().isEmpty(id));
assertNotNull(getFacet().getSet(id));
assertEquals(1, getFacet().getSet(id).size());
assertEquals(t1, getFacet().getSet(id).iterator().next());
assertEventCount(1, 0);
}
use of pcgen.cdom.helper.CNAbilitySelection 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