use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testExplicitOverrideTemplates.
@Test
public void testExplicitOverrideTemplates() {
PCTemplate pct = new PCTemplate();
pct.setName("PCT");
pct.put(ObjectKey.REGION, Region.getConstant("InitRegion"));
pct.put(ObjectKey.SUBREGION, SubRegion.getConstant("InitSubRegion"));
tfacet.add(id, pct, this);
PCTemplate pct2 = new PCTemplate();
pct2.setName("Other");
pct2.put(ObjectKey.REGION, Region.getConstant("TestRegionToo"));
pct2.put(ObjectKey.SUBREGION, SubRegion.getConstant("TestSubRegionToo"));
tfacet.add(id, pct2, this);
assertEquals("TestRegionToo", facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals("TestSubRegionToo", facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals("TestRegionToo (TestSubRegionToo)", facet.getFullRegion(id));
facet.setRegion(id, Region.getConstant(TEST_REGION_NAME));
facet.setSubRegion(id, SubRegion.getConstant(TEST_SUB_REGION_NAME));
assertEquals(TEST_REGION_NAME, facet.getRegion(id));
assertEquals(TEST_REGION_NAME, facet.getCharacterRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getCharacterSubRegion(id));
assertEquals(TEST_FULL_REGION_NAME, facet.getFullRegion(id));
tfacet.remove(id, pct2, this);
assertEquals(TEST_REGION_NAME, facet.getRegion(id));
assertEquals(TEST_REGION_NAME, facet.getCharacterRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getCharacterSubRegion(id));
assertEquals(TEST_FULL_REGION_NAME, facet.getFullRegion(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testRegionSetUseNameFalseRegionDominates.
@Test
public void testRegionSetUseNameFalseRegionDominates() {
PCTemplate pct = new PCTemplate();
pct.put(ObjectKey.REGION, Region.getConstant(TEST_REGION_NAME));
pct.setName("TestTemplate");
pct.put(ObjectKey.USETEMPLATENAMEFORREGION, false);
tfacet.add(id, pct, this);
assertEquals(TEST_REGION_NAME, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(Constants.NONE, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(TEST_REGION_NAME, facet.getFullRegion(id));
tfacet.remove(id, pct, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(Constants.NONE, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE, facet.getFullRegion(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testMultipleSubRegionSetSecondDominatesUseTemplateName.
@Test
public void testMultipleSubRegionSetSecondDominatesUseTemplateName() {
PCTemplate pct = new PCTemplate();
pct.put(ObjectKey.SUBREGION, SubRegion.getConstant(TEST_SUB_REGION_NAME));
tfacet.add(id, pct, this);
PCTemplate pct2 = new PCTemplate();
pct2.setName("TestTemplateToo");
pct2.put(ObjectKey.USETEMPLATENAMEFORSUBREGION, true);
tfacet.add(id, pct2, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals("TestTemplateToo", facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE + " (TestTemplateToo)", facet.getFullRegion(id));
tfacet.remove(id, pct2, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(TEST_SUB_REGION_NAME, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE + " (" + TEST_SUB_REGION_NAME + ")", facet.getFullRegion(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class RegionFacetTest method testUseTemplateNameRegionSubRegionTrue.
@Test
public void testUseTemplateNameRegionSubRegionTrue() {
PCTemplate pct = new PCTemplate();
pct.setName("TestTemplate");
pct.put(ObjectKey.USETEMPLATENAMEFORREGION, true);
pct.put(ObjectKey.USETEMPLATENAMEFORSUBREGION, true);
tfacet.add(id, pct, this);
assertEquals("TestTemplate", facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals("TestTemplate", facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals("TestTemplate (TestTemplate)", facet.getFullRegion(id));
tfacet.remove(id, pct, this);
assertEquals(Constants.NONE, facet.getRegion(id));
assertEquals(Constants.NONE, facet.getCharacterRegion(id));
assertEquals(Constants.NONE, facet.getSubRegion(id));
assertEquals(Constants.NONE, facet.getCharacterSubRegion(id));
assertEquals(Constants.NONE, facet.getFullRegion(id));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GenderFacetTest method testGenderLocked.
@Test
public void testGenderLocked() {
assertTrue(facet.canSetGender(id));
PCTemplate pct = new PCTemplate();
pct.put(ObjectKey.GENDER_LOCK, Gender.Female);
tfacet.add(id, pct, this);
assertFalse(facet.canSetGender(id));
assertEquals(Gender.Female, facet.getGender(id));
tfacet.remove(id, pct, this);
assertTrue(facet.canSetGender(id));
assertEquals(Gender.getDefaultValue(), facet.getGender(id));
}
Aggregations