MCPcopy Create free account
hub / github.com/PCGen/pcgen / testAssociatedBonus

Method testAssociatedBonus

code/src/test/pcgen/core/PObjectTest.java:164–197  ·  view source on GitHub ↗

Test the function of adding a bonus each time an associated value is chosen.

()

Source from the content-addressed store, hash-verified

162 * Test the function of adding a bonus each time an associated value is chosen.
163 */
164 @Test
165 public void testAssociatedBonus()
166 {
167 Ability pObj = new Ability();
168 pObj.setCDOMCategory(BuildUtilities.getFeatCat());
169 pObj.setName("My PObject");
170 pObj.setCDOMCategory(BuildUtilities.getFeatCat());
171 Globals.getContext().unconditionallyProcess(pObj, "CHOOSE", "LANG|ALL");
172 Globals.getContext().unconditionallyProcess(pObj, "MULT", "YES");
173 Globals.getContext().unconditionallyProcess(pObj, "STACK", "YES");
174 Globals.getContext().getReferenceContext().constructCDOMObject(Language.class, "TestPsion 1");
175
176 PlayerCharacter aPC = getCharacter();
177 CNAbility cna = AbstractCharacterTestCase.applyAbility(aPC,
178 BuildUtilities.getFeatCat(), pObj, "TestPsion 1");
179 pObj = cna.getAbility();
180 BonusAddition.applyBonus("SPELLKNOWN|CLASS=TestPsion;LEVEL=1|1", "TestPsion 1",
181 aPC, pObj);
182 aPC.calcActiveBonuses();
183 assertEquals("Should get 1 bonus known spells", 1, (int) aPC
184 .getTotalBonusTo("SPELLKNOWN", "CLASS.TestPsion;LEVEL.1"));
185 AbstractCharacterTestCase.applyAbility(aPC, BuildUtilities.getFeatCat(), pObj, "TestPsion 1");
186 BonusAddition.applyBonus("SPELLKNOWN|CLASS=TestPsion;LEVEL=1|1", "TestPsion 1",
187 aPC, pObj);
188 aPC.calcActiveBonuses();
189 assertEquals("Should get 4 bonus known spells", (2 * 2), (int) aPC
190 .getTotalBonusTo("SPELLKNOWN", "CLASS.TestPsion;LEVEL.1"));
191 AbstractCharacterTestCase.applyAbility(aPC, BuildUtilities.getFeatCat(), pObj, "TestPsion 1");
192 BonusAddition.applyBonus("SPELLKNOWN|CLASS=TestPsion;LEVEL=1|1", "TestPsion 1",
193 aPC, pObj);
194 aPC.calcActiveBonuses();
195 assertEquals("Should get 9 bonus known spells", (3 * 3), (int) aPC
196 .getTotalBonusTo("SPELLKNOWN", "CLASS.TestPsion;LEVEL.1"));
197 }
198
199 /**
200 * Test the function of adding an ability multiple times which has

Callers

nothing calls this directly

Calls 13

setCDOMCategoryMethod · 0.95
getFeatCatMethod · 0.95
getContextMethod · 0.95
applyAbilityMethod · 0.95
getAbilityMethod · 0.95
applyBonusMethod · 0.95
calcActiveBonusesMethod · 0.95
getTotalBonusToMethod · 0.95
constructCDOMObjectMethod · 0.80
setNameMethod · 0.65
getReferenceContextMethod · 0.65

Tested by

no test coverage detected