Search in sources :

Example 16 with ManagerFactory

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

the class DivideNumberModifierTest method testInvalidConstruction.

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

Example 17 with ManagerFactory

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

the class SetOrderedPairModifierTest method testGetModifier.

@Test
public void testGetModifier() {
    ModifierFactory<OrderedPair> factory = new SetModifierFactory();
    Modifier<OrderedPair> modifier = factory.getModifier(5, "3,2", new ManagerFactory() {
    }, null, varScope, opManager);
    assertEquals(5L << 32, modifier.getPriority());
    assertSame(OrderedPair.class, modifier.getVariableFormat());
    assertEquals(new OrderedPair(3, 2), modifier.process(EvalManagerUtilities.getInputEM(new OrderedPair(5, 6))));
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) OrderedPair(pcgen.base.math.OrderedPair) Test(org.junit.Test)

Example 18 with ManagerFactory

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

the class SetStringModifierTest method testGetModifier.

@Test
public void testGetModifier() {
    ModifierFactory<String> factory = new SetModifierFactory();
    Modifier<String> modifier = factory.getModifier(5, "MyString", new ManagerFactory() {
    }, null, varScope, stringManager);
    assertEquals(5L << 32, modifier.getPriority());
    assertSame(String.class, modifier.getVariableFormat());
    assertEquals("MyString", modifier.process(EvalManagerUtilities.getInputEM("Wrong Answer")));
}
Also used : ManagerFactory(pcgen.base.formula.base.ManagerFactory) Test(org.junit.Test)

Example 19 with ManagerFactory

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

the class MinNumberModifierTest method testInvalidConstruction.

@Test
public void testInvalidConstruction() {
    try {
        ModifierFactory m = new MinModifierFactory();
        m.getModifier(100, null, new ManagerFactory() {
        }, null, null, null);
        fail("Expected MaxModifier with null compare 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 20 with ManagerFactory

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

the class SetNumberModifierTest method testGetModifier.

@Test
public void testGetModifier() {
    SetModifierFactory factory = new SetModifierFactory();
    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(6.5, 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