Exemplo n.º 1
0
 private void CreateFact1(System.Collections.Generic.List<RuleEngine.Evidence.EvidenceSpecifier> actionList)
 {
     r1 = new RuleEngine.Evidence.Rule("r1", "f1==f1", actionList, 1, true);
     r1.EvidenceLookup += new EvidenceLookupHandler(EvidenceLookup);
     r1.IsEvaluatable = true;
     r1.Evaluate();
 }
Exemplo n.º 2
0
 private void CreateFact1(System.Collections.Generic.List <RuleEngine.Evidence.EvidenceSpecifier> actionList)
 {
     r1 = new RuleEngine.Evidence.Rule("r1", "f1==f1", actionList, 1, true);
     r1.EvidenceLookup += new EvidenceLookupHandler(EvidenceLookup);
     r1.IsEvaluatable   = true;
     r1.Evaluate();
 }
Exemplo n.º 3
0
        public void TestCloneFunctionality()
        {
            RuleEngine.ROM rom = new RuleEngine.ROM();

            //facts and rules available to these text cases
            RuleEngine.Evidence.Fact f1 = new RuleEngine.Evidence.Fact("f1", 1, 2d, typeof(double));
            RuleEngine.Evidence.Fact f2 = new RuleEngine.Evidence.Fact("f2", 1, 4d, typeof(double));

            RuleEngine.Evidence.Actions.ActionExpression a1 = new RuleEngine.Evidence.Actions.ActionExpression("a1", "f1", "3", 1);
            RuleEngine.Evidence.Actions.ActionExpression a2 = new RuleEngine.Evidence.Actions.ActionExpression("a2", "f2", "3", 1);
            RuleEngine.Evidence.Actions.ActionExecute    a3 = new RuleEngine.Evidence.Actions.ActionExecute("a3", "R2", 1);

            System.Collections.Generic.List <RuleEngine.Evidence.EvidenceSpecifier> actionList = new System.Collections.Generic.List <RuleEngine.Evidence.EvidenceSpecifier>();
            actionList.Add(new RuleEngine.Evidence.EvidenceSpecifier(true, "a1"));
            actionList.Add(new RuleEngine.Evidence.EvidenceSpecifier(true, "a2"));
            actionList.Add(new RuleEngine.Evidence.EvidenceSpecifier(true, "a3"));

            RuleEngine.Evidence.Rule r2 = new RuleEngine.Evidence.Rule("R2", "f1!=f2", actionList, 1, false);

            rom.AddEvidence(f1);
            rom.AddEvidence(f2);
            rom.AddEvidence(a1);
            rom.AddEvidence(a2);
            rom.AddEvidence(a3);
            rom.AddEvidence(r2);

            rom.AddDependentFact("f1", "R2");
            rom.AddDependentFact("f2", "R2");

            f1.IsEvaluatable = true;
            f2.IsEvaluatable = true;
            a1.IsEvaluatable = true;
            a2.IsEvaluatable = true;
            a3.IsEvaluatable = true;
            r2.IsEvaluatable = true;

            RuleEngine.ROM rom2 = (RuleEngine.ROM)rom.Clone();
            rom2.Evaluate();

            Assert.AreEqual("3", rom2["f1"].Value.ToString());
            Assert.AreEqual("3", rom2["f2"].Value.ToString());
            Assert.AreNotEqual(rom["f1"].Value.ToString(), rom2["f1"].Value.ToString());
        }