Test the function of the getHighestLevelSpell method. @throws PersistenceLayerException the persistence layer exception
()
| 468 | * @throws PersistenceLayerException the persistence layer exception |
| 469 | */ |
| 470 | @Test |
| 471 | void testGetHighestLevelSpell() throws PersistenceLayerException |
| 472 | { |
| 473 | LoadContext context = Globals.getContext(); |
| 474 | PCClass megaCasterClass = new PCClass(); |
| 475 | megaCasterClass.setName("MegaCaster"); |
| 476 | BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane"); |
| 477 | context.unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA"); |
| 478 | megaCasterClass.put(ObjectKey.SPELLBOOK, false); |
| 479 | megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false); |
| 480 | context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(1), "KNOWN", "4,2,2,3,4,5"); |
| 481 | context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(1), "CAST", "3,1,2,3,4,5"); |
| 482 | context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(2), "KNOWN", "4,2,2,3,4,5,6,7,8,9,10"); |
| 483 | context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(2), "CAST", "3,1,2,3,4,5,6,7,8,9,10"); |
| 484 | Globals.getContext().getReferenceContext().importObject(megaCasterClass); |
| 485 | |
| 486 | finishLoad(); |
| 487 | |
| 488 | final PlayerCharacter character = getCharacter(); |
| 489 | assertEquals(10, |
| 490 | character.getSpellSupport(megaCasterClass).getHighestLevelSpell(), "Highest spell level for class" |
| 491 | ); |
| 492 | |
| 493 | character.incrementClassLevel(1, megaCasterClass); |
| 494 | PCClass charClass = |
| 495 | character.getClassKeyed(megaCasterClass.getKeyName()); |
| 496 | assertEquals(10, |
| 497 | character.getSpellSupport(charClass).getHighestLevelSpell(), "Highest spell level for character's class" |
| 498 | ); |
| 499 | |
| 500 | String sbook = Globals.getDefaultSpellBook(); |
| 501 | |
| 502 | String cast = |
| 503 | character.getSpellSupport(charClass).getCastForLevel(10, sbook, true, false, character) |
| 504 | + character.getSpellSupport(charClass).getBonusCastForLevelString(10, sbook, character); |
| 505 | assertEquals( |
| 506 | "0", |
| 507 | cast, "Should not be able to cast 10th level spells at 1st level" |
| 508 | ); |
| 509 | cast = |
| 510 | character.getSpellSupport(charClass).getCastForLevel(5, sbook, true, false, character) |
| 511 | + character.getSpellSupport(charClass).getBonusCastForLevelString(5, sbook, character); |
| 512 | assertEquals( |
| 513 | "5", cast, "Should be able to cast 5th level spells at 1st level"); |
| 514 | |
| 515 | Ability casterFeat = new Ability(); |
| 516 | FeatLoader featLoader = new FeatLoader(); |
| 517 | CampaignSourceEntry source; |
| 518 | try |
| 519 | { |
| 520 | source = new CampaignSourceEntry(new Campaign(), |
| 521 | new URI("file:/" + getClass().getName() + ".java")); |
| 522 | } |
| 523 | catch (URISyntaxException e) |
| 524 | { |
| 525 | throw new UnreachableError(e); |
| 526 | } |
| 527 | featLoader |
nothing calls this directly
no test coverage detected