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

Class SpellLevelTest

code/src/test/pcgen/core/analysis/SpellLevelTest.java:52–117  ·  view source on GitHub ↗

The Class SpellLevelTest checks the SpellLevel class.

Source from the content-addressed store, hash-verified

50 *
51 */
52public class SpellLevelTest extends AbstractCharacterTestCase
53{
54
55 private static KnownSpellFacet listManagerFacet = FacetLibrary
56 .getFacet(KnownSpellFacet.class);
57
58 /**
59 *
60 * @throws Exception
61 */
62 @Test
63 public void testGetPCBasedBonusKnownSpells() throws Exception
64 {
65 LoadContext context = Globals.getContext();
66 CampaignSourceEntry source;
67 try
68 {
69 source = new CampaignSourceEntry(new Campaign(),
70 new URI("file:/" + getClass().getName() + ".java"));
71 }
72 catch (URISyntaxException e)
73 {
74 throw new UnreachableError(e);
75 }
76
77
78 final String classLine =
79 "CLASS:Sorcerer TYPE:Base.PC SPELLSTAT:CHA SPELLTYPE:Arcane MEMORIZE:NO BONUS:CASTERLEVEL|Sorcerer|CL";
80 PCClassLoader classLoader = new PCClassLoader();
81 PCClass pcc = classLoader.parseLine(context, null, classLine, source);
82
83 Spell spell = TestHelper.makeSpell("Bless");
84
85 String abilityLine =
86 "Spell bonanza CATEGORY:FEAT SPELLKNOWN:CLASS|Sorcerer=3|KEY_Bless";
87 AbilityLoader abilityLoader = new AbilityLoader();
88 abilityLoader.parseLine(context, null, abilityLine, source);
89 Ability ab1 = Globals.getContext().getReferenceContext()
90 .getManufacturerId(BuildUtilities.getFeatCat()).getActiveObject("Spell bonanza");
91
92 // Do the post parsing cleanup
93 finishLoad();
94
95 PlayerCharacter aPC = getCharacter();
96
97 Collection<Integer> levels = listManagerFacet.getScopes2(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST));
98 assertEquals("Initial number of spell levels incorrect", 0, levels.size());
99
100 addAbility(BuildUtilities.getFeatCat(), ab1);
101
102 // Now for the tests
103 levels = listManagerFacet.getScopes2(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST));
104 assertEquals("Incorrect number of spell levels returned", 1, levels.size());
105 assertEquals("Incorrect spell level returned", Integer.valueOf(3), levels.iterator().next());
106 Collection<Spell> result = listManagerFacet.getSet(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST), 3);
107 assertEquals("Incorrect number of spells returned", 1, result.size());
108 assertEquals("Incorrect spell returned", spell, result.iterator().next());
109

Callers

nothing calls this directly

Calls 1

getFacetMethod · 0.95

Tested by

no test coverage detected