public void AfterBinderRetraction() { Character theDuke = new Character("The Duke", "hello world"); Hashtable bo = new Hashtable(); bo.Add("THEDUKE", theDuke); // first test to confirm that a pre-existing fact is not rededucted IInferenceEngine ie = new IEImpl(new FlowEngineBinder(ruleFilesFolder + "testbinder3.ruleml.xbre", BindingTypes.BeforeAfter)); ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "testbinder.ruleml", FileAccess.Read)); ie.Assert(new Fact("retract_target", "education", new Individual(theDuke), new Individual("polite"))); ie.NewFactHandler += new NewFactEvent(ShowAllNewFacts); deducted = 0; ie.Process(bo); Assert.AreEqual(0, deducted, "The Duke was already polite!"); // second test to confirm that retracting the fact in the after binder restarts inference ie = new IEImpl(new FlowEngineBinder(ruleFilesFolder + "testbinder4.ruleml.xbre", BindingTypes.BeforeAfter)); ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "testbinder.ruleml", FileAccess.Read)); ie.Assert(new Fact("retract_target", "education", new Individual(theDuke), new Individual("polite"))); ie.NewFactHandler += new NewFactEvent(ShowAllNewFacts); deducted = 0; ie.Process(bo); Assert.AreEqual(1, deducted, "The Duke was re-deducted polite!"); }
private void RunTestBoundFormulas(IBinder binder, IRuleBaseAdapter rba) { // regression test for RFE 1504353 IInferenceEngine ie = new IEImpl(binder); ie.LoadRuleBase(rba); Assert.IsTrue(ie.Assert(new Fact("operandA", new Individual(23)))); Assert.IsTrue(ie.Assert(new Fact("operandB", new Individual(7)))); ie.Process(); Assert.AreEqual(4, ie.FactsCount); Assert.IsTrue(ie.FactExists(new Fact("resultA-B", new Individual(16))), "resultA-B is wrong"); Assert.IsTrue(ie.FactExists(new Fact("resultB-A", new Individual(-16))), "resultB-A is wrong"); }
public void IsolatedThreadSafeMemoryCloning() { //Regression test for bug #1340799 IInferenceEngine ie1 = new IEImpl(ThreadingModelTypes.Multi); ie1.LoadRuleBase(NewTestAdapter()); int ie1facts = ie1.FactsCount; IInferenceEngine ie2 = new IEImpl(ThreadingModelTypes.Multi); ie2.LoadRuleBase(NewGedcomAdapter()); ie2.Assert(new Fact("sex", new Individual("dad"), new Individual("m"))); ie2.NewWorkingMemory(WorkingMemoryTypes.Isolated); Assert.AreEqual(ie1facts, ie1.FactsCount, "FactsCount has wrongly changed"); }