Search in sources :

Example 1 with ManagerFactory

use of pcgen.base.formula.base.ManagerFactory in project pcgen by PCGen.

the class SetOrderedPairModifierTest method testInvalidConstruction.

@Test
public void testInvalidConstruction() {
    try {
        SetModifierFactory m = new SetModifierFactory();
        m.getModifier(100, null, new ManagerFactory() {
        }, null, null, null);
        fail("Expected SetModifier with null set value to fail");
    } catch (IllegalArgumentException | NullPointerException e) {
    //Yep!
    }
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) Test(org.junit.Test)

Example 2 with ManagerFactory

use of pcgen.base.formula.base.ManagerFactory in project pcgen by PCGen.

the class SetStringModifierTest method testInvalidConstruction.

@Test
public void testInvalidConstruction() {
    try {
        SetModifierFactory m = new SetModifierFactory();
        m.getModifier(100, null, new ManagerFactory() {
        }, null, null, null);
        fail("Expected SetModifier with null set value to fail");
    } catch (IllegalArgumentException | NullPointerException e) {
    //Yep!
    }
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) Test(org.junit.Test)

Example 3 with ManagerFactory

use of pcgen.base.formula.base.ManagerFactory in project pcgen by PCGen.

the class SetNumberModifierTest method testGetFormulaModifier.

@Test
public void testGetFormulaModifier() {
    SplitFormulaSetup setup = new SplitFormulaSetup();
    setup.loadBuiltIns();
    setup.getLegalScopeLibrary().registerScope(varScope);
    IndividualSetup iSetup = new IndividualSetup(setup, "Global", new SimpleVariableStore());
    SetModifierFactory factory = new SetModifierFactory();
    Modifier<Number> modifier = factory.getModifier(35, "6+5", new ManagerFactory() {
    }, iSetup.getFormulaManager(), varScope, numManager);
    assertEquals((35L << 32) + factory.getInherentPriority(), modifier.getPriority());
    assertSame(Number.class, modifier.getVariableFormat());
    EvaluationManager evalManager = EvalManagerUtilities.getInputEM(4.3);
    assertEquals(11, modifier.process(evalManager.getWith(EvaluationManager.FMANAGER, iSetup.getFormulaManager())));
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) ManagerFactory(pcgen.base.formula.base.ManagerFactory) SimpleVariableStore(pcgen.base.formula.inst.SimpleVariableStore) IndividualSetup(pcgen.base.solver.IndividualSetup) EvaluationManager(pcgen.base.formula.base.EvaluationManager) Test(org.junit.Test)

Example 4 with ManagerFactory

use of pcgen.base.formula.base.ManagerFactory in project pcgen by PCGen.

the class MultiplyNumberModifierTest method testInvalidConstruction.

@Test
public void testInvalidConstruction() {
    try {
        ModifierFactory m = new MultiplyModifierFactory();
        m.getModifier(100, null, new ManagerFactory() {
        }, null, null, null);
        fail("Expected MultiplyModifier with null multiply value to fail");
    } catch (IllegalArgumentException | NullPointerException e) {
    //Yep!
    }
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) ModifierFactory(pcgen.rules.persistence.token.ModifierFactory) Test(org.junit.Test)

Example 5 with ManagerFactory

use of pcgen.base.formula.base.ManagerFactory in project pcgen by PCGen.

the class MultiplyNumberModifierTest method testGetModifier.

@Test
public void testGetModifier() {
    MultiplyModifierFactory factory = new MultiplyModifierFactory();
    Modifier<Number> modifier = factory.getModifier(35, "6.5", new ManagerFactory() {
    }, null, varScope, numManager);
    assertEquals((35L << 32) + factory.getInherentPriority(), modifier.getPriority());
    assertSame(Number.class, modifier.getVariableFormat());
    assertEquals(27.95, modifier.process(EvalManagerUtilities.getInputEM(4.3)));
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) Test(org.junit.Test)

Aggregations

ManagerFactory (pcgen.base.formula.base.ManagerFactory)21 Test (org.junit.Test)20 ModifierFactory (pcgen.rules.persistence.token.ModifierFactory)8 PCGenModifier (pcgen.base.calculation.PCGenModifier)3 CalculationModifier (pcgen.base.calculation.CalculationModifier)2 NEPCalculation (pcgen.base.calculation.NEPCalculation)2 ScopeInstance (pcgen.base.formula.base.ScopeInstance)2 VariableID (pcgen.base.formula.base.VariableID)2 ProcessCalculation (pcgen.cdom.content.ProcessCalculation)2 Equipment (pcgen.core.Equipment)2 Before (org.junit.Before)1 EvaluationManager (pcgen.base.formula.base.EvaluationManager)1 FunctionLibrary (pcgen.base.formula.base.FunctionLibrary)1 LegalScope (pcgen.base.formula.base.LegalScope)1 LegalScopeLibrary (pcgen.base.formula.base.LegalScopeLibrary)1 OperatorLibrary (pcgen.base.formula.base.OperatorLibrary)1 VariableLibrary (pcgen.base.formula.base.VariableLibrary)1 ScopeInstanceFactory (pcgen.base.formula.inst.ScopeInstanceFactory)1 SimpleFormulaManager (pcgen.base.formula.inst.SimpleFormulaManager)1 SimpleFunctionLibrary (pcgen.base.formula.inst.SimpleFunctionLibrary)1