コード例 #1
0
ファイル: TestEngineMisc.cs プロジェクト: ilkerhalil/NxBRE
        private void PerformNafSupport(IRuleBaseAdapter irba)
        {
            ie.LoadRuleBase(irba);

            deductionsToCheck = new string[] { "Detector In Room{A102}", "Detector In Room{A100}",
                                               "Firemen In Room{A102}" };
            qrs = ie.RunQuery("Safe Room List");
            Assert.AreEqual(3, qrs.Count, "(1) Safe Room List: Count");
            ParseResult();
            Assert.IsFalse(wrongDeduction, "(1) Safe Room List Deductions OK");

            deductionsToCheck = new string[] { "Alarm Fault In Room{Smoke Detected,A100}",
                                               "Safe Room{A102}" };
            NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);

            ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
            ie.NewFactHandler -= henf;

            deductionsToCheck = new string[] { "Detector In Room{A102}", "Firemen In Room{A102}" };
            qrs = ie.RunQuery("Safe Room List");
            Assert.AreEqual(2, qrs.Count, "(2) Safe Room List: Count");
            ParseResult();
            Assert.IsFalse(wrongDeduction, "(2) Safe Room List Deductions OK");

            deductionsToCheck = null;
        }
コード例 #2
0
ファイル: TestEngineMisc.cs プロジェクト: ilkerhalil/NxBRE
        private void PerformCountingImpFunctionRelSupport(IRuleBaseAdapter irba, bool withBinder)
        {
            ie.LoadRuleBase(irba);

            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            deductionsToCheck = new string[] { "Result{Physics,Passed}", "Result{Poetry,Passed}",
                                               "Result Count{2,Passed}" };
            NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);

            ie.NewFactHandler += henf;
            Process(withBinder?new Hashtable():null);
            Assert.AreEqual(3, deducted, "(1) Deducted");
            Assert.IsFalse(wrongDeduction, "(1) Deductions OK");
            ie.NewFactHandler -= henf;

            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            // let's turn maths failure into success
            ie.Retract("Maths Score");
            ie.Assert(new Fact("Score", new Individual("Maths"), new Individual(88)));
            deductionsToCheck = new string[] { "Result{Physics,Passed}", "Result{Poetry,Passed}",
                                               "Result{Maths,Passed}", "Result Count{3,Passed}",
                                               "Graduation Success{}" };
            henf = new NewFactEvent(HandleExpectedNewFact);
            ie.NewFactHandler += henf;
            Process(withBinder?new Hashtable():null);
            Assert.AreEqual(5, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Deductions OK");
            ie.NewFactHandler -= henf;

            deductionsToCheck = null;
        }
コード例 #3
0
ファイル: TestEngineMisc.cs プロジェクト: plamikcho/xbrlpoc
        public void AgendaScheduler()
        {
            // regression test for bug 1713544
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "agenda-scheduler-test.ruleml", FileAccess.Read));

            deductionsToCheck = new string[]{"deduction{B}", "then{C}"};
              	NewFactEvent honf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += honf;

              	Process();

              	Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");

            ie.NewFactHandler -= honf;
        }
コード例 #4
0
ファイル: TestEngineMisc.cs プロジェクト: ilkerhalil/NxBRE
        public void AgendaScheduler()
        {
            // regression test for bug 1713544
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + "agenda-scheduler-test.ruleml", FileAccess.Read));

            deductionsToCheck = new string[] { "deduction{B}", "then{C}" };
            NewFactEvent honf = new NewFactEvent(HandleExpectedNewFact);

            ie.NewFactHandler += honf;

            Process();

            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");

            ie.NewFactHandler -= honf;
        }
コード例 #5
0
ファイル: IEGUIFacade.cs プロジェクト: ilkerhalil/NxBRE
        public void Process(NewFactEvent nfh, NewFactEvent dfh, NewFactEvent mfh)
        {
            ie.NewFactHandler    += nfh;
            ie.DeleteFactHandler += dfh;
            ie.ModifyFactHandler += mfh;

            if (ie.BinderType != null)
            {
                ie.Process(new Hashtable());
            }
            else
            {
                ie.Process();
            }

            ie.DeleteFactHandler -= dfh;
            ie.NewFactHandler    -= nfh;
        }
コード例 #6
0
ファイル: TestEngineMisc.cs プロジェクト: ilkerhalil/NxBRE
        public void DiscountVisio2003Pages()
        {
            deductionsToCheck = new string[] { "Customer Rating{Peter Miller,Premium}" };
            NewFactEvent honf = new NewFactEvent(HandleOrderedNewFact);

            ie.NewFactHandler += honf;

            ie.LoadRuleBase(new Visio2003Adapter(ruleFilesFolder + "discount.vdx",
                                                 FileAccess.Read,
                                                 "Customer Rules",
                                                 "Customer Data"));
            Process();
            Assert.AreEqual(1, deducted, "(1) Deducted");
            Assert.AreEqual(2, ie.FactsCount, "(2) Total Facts Count");
            Assert.IsFalse(wrongDeduction, "(3) Query Results");

            ie.NewFactHandler -= honf;
            deductionsToCheck  = null;
        }
コード例 #7
0
        public virtual void AdvancedImplicationLogicalSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Account a50 = new Account(123, 50);
            ie.Assert(new Fact("id",
                               new Individual(a50),
                               new Individual(a50.Id)));
            ie.Assert(new Fact("balance",
                               new Individual(a50),
                               new Individual(a50.Balance)));

            Account a100 = new Account(456, 100);
            ie.Assert(new Fact("id",
                               new Individual(a100),
                               new Individual(a100.Id)));
            ie.Assert(new Fact("balance",
                               new Individual(a100),
                               new Individual(a100.Balance)));

            Account a200 = new Account(789, 200);
            ie.Assert(new Fact("id",
                               new Individual(a200),
                               new Individual(a200.Id)));
            ie.Assert(new Fact("balance",
                               new Individual(a200),
                               new Individual(a200.Balance)));

            deductionsToCheck = new string[] {"testAandForGorAandG{ACCNT#789 $200}",
                                                                                "testCorBandA{ACCNT#456 $100}", "testCorBandA{ACCNT#123 $50}",
                                                                                "testAandBorC{ACCNT#123 $50}", "testAandBorC{ACCNT#456 $100}",
                                                                                "testAorDandEandBorC{ACCNT#123 $50}",
                                                                                "testAandForGorAandG{ACCNT#123 $50}"};

              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(7, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");

              	ie.NewFactHandler -= henf;
              	deductionsToCheck = null;
        }
コード例 #8
0
        private void PerformLoadTest(string ruleFile)
        {
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + ruleFile, FileAccess.Read));

            Assert.AreEqual(2, ie.FactsCount, "Initial facts count");

            string[] factsToCheck = new string[] {};
            for(IEnumerator e = ie.Facts ; e.MoveNext();) {
                Fact fact = (Fact) e.Current;
                Assert.IsTrue((fact.ToString() == "sell{John,Mary,XMLBible}") | ((fact.ToString() == "keep{Mary,XMLBible}")), "Initial facts value");
            }

            deductionsToCheck = new string[] {"buy{Mary,John,XMLBible}", "own{Mary,XMLBible}"};

              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
              	ie.NewFactHandler -= henf;
              	deductionsToCheck = null;
        }
コード例 #9
0
        public virtual void AndBlockContainingOnlyOrBlocks()
        {
            // regression test for bug 1358781
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("dog",
                                             new Individual("foo"),
                                             new Individual("Black"))), "Asserted dog");

            Assert.IsTrue(ie.Assert(new Fact("cat",
                                             new Individual("foo"),
                                             new Individual("Brown"))), "Asserted cat");

            deductionsToCheck = new string[] {"result{foo}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;
        }
コード例 #10
0
        private void PerformLoadTest(string ruleFile)
        {
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + ruleFile, FileAccess.Read));

            Assert.AreEqual(2, ie.FactsCount, "Initial facts count");

            string[] factsToCheck = new string[] {};
            for (IEnumerator e = ie.Facts; e.MoveNext();)
            {
                Fact fact = (Fact)e.Current;
                Assert.IsTrue((fact.ToString() == "sell{John,Mary,XMLBible}") | ((fact.ToString() == "keep{Mary,XMLBible}")), "Initial facts value");
            }

            deductionsToCheck = new string[] { "buy{Mary,John,XMLBible}", "own{Mary,XMLBible}" };

            NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);

            ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
            ie.NewFactHandler -= henf;
            deductionsToCheck  = null;
        }
コード例 #11
0
        public void PreconditionSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredX")));
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredY")));

            // Isolate memory for a first round of test - step by step
            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            Process();
            Assert.AreEqual(0, deducted, "(1) Deducted");

            // The fact allows the precondition rule to fire (first deduction), then Y can fire (second deduction)
            // Z will not fire because if its triggering flag is not asserted, therefore X will not fire.
            ie.Assert(new Fact("flag", new Individual("trigger"), new Individual("preconditionTrigger")));
            Process();
            Assert.AreEqual(2, deducted, "(2) Deducted");

            // This time Z and X should fire
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredZ")));
            Process();
            Assert.AreEqual(2, deducted, "(3) Deducted");

            // Come back to the global one for a second test - all in one
            ie.NewWorkingMemory(WorkingMemoryTypes.Global);
            ie.Assert(new Fact("flag", new Individual("trigger"), new Individual("preconditionTrigger")));
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredZ")));
            deductionsToCheck = new string[]{"preconditionTriggered{trigger}",
                                                                             "preconditionZ{probe}",
                                                                             "preconditionX{probe}",
                                                                             "preconditionY{probe}"};
              	NewFactEvent honf = new NewFactEvent(HandleOrderedNewFact);
              	ie.NewFactHandler += honf;
            Process();
            Assert.AreEqual(4, deducted, "(4) Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
              	ie.NewFactHandler -= honf;
              	deductionsToCheck = null;

            // Another process should lead to nothng
            Process();
            Assert.AreEqual(0, deducted, "(5) Deducted");
        }
コード例 #12
0
        public void OrNafCombo()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("CheckProductInfo", new Individual("true"))), "Asserted trigger fact");

              	ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            Process();
            Assert.AreEqual(0, deducted, "(1) Deducted");

            deductionsToCheck = new string[] {"NotAllCategoriesCovered{true}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

              	ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
              	Assert.IsTrue(ie.Retract("Honda Regular"), "(2) Retracted Regular");
            Process();
            Assert.IsFalse(wrongDeduction, "(2) Wrong deduction");
            Assert.AreEqual(1, deducted, "(2) Deducted");

              	ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
              	Assert.IsTrue(ie.Retract("Porsche Luxury"), "(3) Retracted Luxury");
            Process();
            Assert.IsFalse(wrongDeduction, "(3) Wrong deduction");
            Assert.AreEqual(1, deducted, "(3) Deducted");

              	ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
              	Assert.IsTrue(ie.Retract("Honda Regular"), "(4) Retracted Regular");
              	Assert.IsTrue(ie.Retract("Porsche Luxury"), "(4) Retracted Luxury");
            Process();
            Assert.IsFalse(wrongDeduction, "(4) Wrong deduction");
            Assert.AreEqual(1, deducted, "(4) Deducted");

              	ie.NewFactHandler -= henf;
        }
コード例 #13
0
        public void ObjectPredicates()
        {
            ie.LoadRuleBase(NewTestAdapter());

            // Account ID 1234 should not be valid
            Account a1234 = new Account(1234, 25);
            ie.Assert(new Fact("balance",
                               new Individual(a1234),
                               new Individual("actualValue"),
                               new Individual(a1234.Balance)));

            ie.Assert(new Fact("balance",
                               new Individual(a1234),
                               new Individual("expectedValue"),
                               new Individual(50)));

            // Account ID 9876 should be valid
            Account a9876 = new Account(9876, 50);
            ie.Assert(new Fact("balance",
                               new Individual(a9876),
                               new Individual("actualValue"),
                               new Individual(a9876.Balance)));

            ie.Assert(new Fact("balance",
                               new Individual(a9876),
                               new Individual("expectedValue"),
                               new Individual(50)));

            deductionsToCheck = new string[] {"isValid{ACCNT#9876 $50}", "isTwentyFive{ACCNT#1234 $25}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

              	ie.NewFactHandler -= henf;

            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            Assert.AreEqual(2, deducted, "Deducted");

            qrs = ie.RunQuery(new Query(new AtomGroup(AtomGroup.LogicalOperator.And,
                                                      new Atom("isValid", new Variable("account")))));
            Assert.AreEqual(1, qrs.Count, "Query Size");
            if (qrs.Count > 0) Assert.AreEqual(a9876, qrs[0][0].Members[0].Value, "Correct Result");
        }
コード例 #14
0
        public void MutexSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());
            Fact locker = new Fact("locker", "flag", new Individual("lock"), new Individual("mutexLock"));
            ie.Assert(locker);
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredA")));
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredB")));
            Process();
            Assert.AreEqual(1, deducted, "(1) Deducted");

            // no garantee if A or B is deducted because they implications have same priority level
            ie.Retract(locker);
            Process();
            Assert.AreEqual(1, deducted, "(2) Deducted");

            // C should be deducted
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("triggeredC")));
            deductionsToCheck = new string[] {"mutexC{probe}"};
              	NewFactEvent honf = new NewFactEvent(HandleOrderedNewFact);
              	ie.NewFactHandler += honf;
            Process();
            Assert.AreEqual(1, deducted, "(3) Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
              	ie.NewFactHandler -= honf;
              	deductionsToCheck = null;

            // nothing must be rededucted as
            Process();
            Assert.AreEqual(0, deducted, "(3) Deducted");
        }
コード例 #15
0
        public virtual void ImplicationVarLessSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());
            ie.Assert(new Fact("varless.value", new Individual("A")));
            ie.Assert(new Fact("varless.value", new Individual("E")));
            ie.Assert(new Fact("varless.value", new Individual("F")));

            deductionsToCheck = new string[]{"first.deduction{correct}", "third.deduction{correct}", "forth.deduction{correct}"};
              	NewFactEvent honf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += honf;

              	Process();

              	Assert.AreEqual(3, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");

            ie.NewFactHandler -= honf;
        }
コード例 #16
0
        public void ImplicationLogicalSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("andTestA")));
            ie.Assert(new Fact("flag", new Individual("other"), new Individual("andTestA")));
            Process();
            Assert.AreEqual(0, deducted, "(1) Deducted");

            deductionsToCheck = new string[] {"testAandB{probe}", "testBorC{probe}", "testBorC{other}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("andTestB")));
            ie.Assert(new Fact("flag", new Individual("other"), new Individual("andTestC")));
            Process();
            Assert.AreEqual(3, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Wrong deduction");

              	ie.NewFactHandler -= henf;
              	deductionsToCheck = null;
        }
コード例 #17
0
ファイル: TestEngineMisc.cs プロジェクト: plamikcho/xbrlpoc
        private void PerformCountingImpFunctionRelSupport(IRuleBaseAdapter irba, bool withBinder)
        {
            ie.LoadRuleBase(irba);

            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            deductionsToCheck = new string[] {"Result{Physics,Passed}", "Result{Poetry,Passed}",
                                                                                "Result Count{2,Passed}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
              	Process(withBinder?new Hashtable():null);
            Assert.AreEqual(3, deducted, "(1) Deducted");
            Assert.IsFalse(wrongDeduction, "(1) Deductions OK");
              	ie.NewFactHandler -= henf;

            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);
            // let's turn maths failure into success
            ie.Retract("Maths Score");
            ie.Assert(new Fact("Score", new Individual("Maths"), new Individual(88)));
            deductionsToCheck = new string[] {"Result{Physics,Passed}", "Result{Poetry,Passed}",
                                                                                "Result{Maths,Passed}", "Result Count{3,Passed}",
                                                                                "Graduation Success{}"};
              	henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            Process(withBinder?new Hashtable():null);
            Assert.AreEqual(5, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Deductions OK");
              	ie.NewFactHandler -= henf;

            deductionsToCheck = null;
        }
コード例 #18
0
ファイル: TestEngineMisc.cs プロジェクト: plamikcho/xbrlpoc
        private void PerformNafSupport(IRuleBaseAdapter irba)
        {
            ie.LoadRuleBase(irba);

            deductionsToCheck = new string[] {"Detector In Room{A102}", "Detector In Room{A100}",
                                                                                "Firemen In Room{A102}"};
            qrs = ie.RunQuery("Safe Room List");
            Assert.AreEqual(3, qrs.Count, "(1) Safe Room List: Count");
            ParseResult();
            Assert.IsFalse(wrongDeduction, "(1) Safe Room List Deductions OK");

            deductionsToCheck = new string[] {"Alarm Fault In Room{Smoke Detected,A100}",
                                                                                "Safe Room{A102}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");
              	ie.NewFactHandler -= henf;

            deductionsToCheck = new string[] {"Detector In Room{A102}", "Firemen In Room{A102}"};
            qrs = ie.RunQuery("Safe Room List");
            Assert.AreEqual(2, qrs.Count, "(2) Safe Room List: Count");
            ParseResult();
            Assert.IsFalse(wrongDeduction, "(2) Safe Room List Deductions OK");

            deductionsToCheck = null;
        }
コード例 #19
0
        public void PrioritySupport()
        {
            deductionsToCheck = new string[]{"higherImpl{probe}", "mediumImpl{probe}", "lowerImpl{probe}"};
              	NewFactEvent honf = new NewFactEvent(HandleOrderedNewFact);
              	ie.NewFactHandler += honf;

            ie.LoadRuleBase(NewTestAdapter());
            ie.Assert(new Fact("flag", new Individual("probe"), new Individual("testPriority")));
            Process();
            Assert.AreEqual(3, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Deductions OK");

              	ie.NewFactHandler -= honf;
              	deductionsToCheck = null;
        }
コード例 #20
0
        public virtual void EquivalentTwoLevels()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("possess",
                                             new Individual("mary"),
                                             new Individual("book"))), "Asserted trigger fact");

            deductionsToCheck = new string[] {"gift{mary,book}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;
        }
コード例 #21
0
        public virtual void EquivalentDirect()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("belongs",
                                             new Individual("book"),
                                             new Individual("mary"))), "Asserted trigger fact");

            ie.NewWorkingMemory(WorkingMemoryTypes.Isolated);

            deductionsToCheck = new string[] {"gift{mary,book}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;

            ie.DisposeIsolatedMemory();

            Assert.IsTrue(ie.Assert(new Fact("bought",
                                             new Individual("mary"),
                                             new Individual("book"))), "Asserted naf blocker fact");

            Process();

            Assert.AreEqual(0, deducted, "Deducted");
        }
コード例 #22
0
        public virtual void DataInBodySupport()
        {
            // regression test for bug 1469851
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("Threshold-Check", new Individual("PASS"), new Individual(50))), "Asserted passing fact");
            Assert.IsTrue(ie.Assert(new Fact("Threshold-Check", new Individual("FAIL"), new Individual(5))), "Asserted failing fact");

            deductionsToCheck = new string[] {"Threshold-Result{PASS,50}"};
              		NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              		ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;
        }
コード例 #23
0
        public virtual void SlotSupport()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("success", new Individual("Bobby"), new Individual(1000))), "Asserted gold fact");

            deductionsToCheck = new string[] {"bonus{Bobby,amount=3000}", "miles{Bobby,5000}"};
              		NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              		ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(2, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;

            qrs = ie.RunQuery(new Query(new AtomGroup(AtomGroup.LogicalOperator.And,
                                                      new Atom("bonus", new Individual("Bobby"), new Variable("bonus amount")))));

            Assert.AreEqual(1, qrs.Count, "Query Size");

            if (qrs.Count > 0) Assert.AreEqual(3000, qrs[0][0].GetPredicateValue("amount"), "Correct Sloted Result");
        }
コード例 #24
0
        public virtual void SlotContributeNamedValues()
        {
            // regression test for RFE 1483072
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("Slot-Threshold-Check", new Individual("PASS"), new Individual(50))), "Asserted passing fact");
            Assert.IsTrue(ie.Assert(new Fact("Slot-Threshold-Check", new Individual("FAIL"), new Individual(5))), "Asserted failing fact");

            deductionsToCheck = new string[] {"Slot-Threshold-Result{PASS,50}"};
              		NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              		ie.NewFactHandler += henf;

              	//logThreshold = LogEventImpl.DEBUG;
            Process();

            Assert.AreEqual(1, deducted, "(1) Deducted");
            Assert.IsFalse(wrongDeduction, "(1) Wrong deduction");

            Assert.IsTrue(ie.Assert(new Fact("Slot-Contribution", new Individual("SUCCESS"), new Individual("PASS"), new Individual(50))), "Asserted second passing fact");

            deductionsToCheck = new string[] {"Slot-Contribution-Result{PASS,50}", "Slot-Contribution-Result-Bis{PASS,50}"};

            Process();

            Assert.AreEqual(2, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Wrong deduction");

            ie.NewFactHandler -= henf;
        }
コード例 #25
0
        public void CheckNonStrictImplicationBehavior()
        {
            ie.LoadRuleBase(NewTestAdapter());
            Assert.IsFalse(((IEImpl)ie).strictImplication, "Ensure IE is not strict");

            Assert.IsTrue(ie.Assert(new Fact("flagStrictA", new Individual("something"))), "Asserted fact A");
            Process();
            Assert.AreEqual(0, deducted, "(1) Deducted");

            Assert.IsTrue(ie.Assert(new Fact("flagStrictB", new Individual("anything"), new Individual("whatever"))), "Asserted fact B");
            deductionsToCheck = new string[] {"testStrict{anything,whatever}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;
            Process();
            Assert.AreEqual(1, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Wrong deduction");
              	ie.NewFactHandler -= henf;
        }
コード例 #26
0
        public void Gedcom()
        {
            deductionsToCheck = new string[]{
                "sibling{Girl,Boy}", "sibling{Boy,Girl}", "parent{Girl,Daddy}",
                "parent{Girl,Mummy}", "parent{Boy,Daddy}", "parent{Boy,Mummy}", "ancestor{Girl,Daddy}",
                "ancestor{Girl,Mummy}", "ancestor{Boy,Daddy}", "ancestor{Boy,Mummy}", "descendent{Daddy,Girl}",
                "descendent{Mummy,Girl}", "descendent{Daddy,Boy}", "descendent{Mummy,Boy}", "child{Daddy,Girl}",
                "child{Mummy,Girl}", "child{Daddy,Boy}", "child{Mummy,Boy}", "spouse{Daddy,Mummy}", "spouse{Mummy,Daddy}",
                "wife{Daddy,Mummy}", "daughter{Daddy,Girl}", "daughter{Mummy,Girl}", "mother{Girl,Mummy}",
                "mother{Boy,Mummy}", "sister{Boy,Girl}", "son{Daddy,Boy}", "son{Mummy,Boy}", "father{Girl,Daddy}",
                "father{Boy,Daddy}", "brother{Girl,Boy}", "husband{Mummy,Daddy}", "ancestor{Daddy,Old'Pa}",
                "descendent{Old'Pa,Daddy}", "ancestor{Girl,Old'Pa}", "ancestor{Boy,Old'Pa}", "descendent{Old'Pa,Girl}",
                "descendent{Old'Pa,Boy}", "grandparent{Girl,Old'Pa}", "grandparent{Boy,Old'Pa}", "granddaughter{Girl,Old'Pa}",
                "grandchild{Old'Pa,Girl}", "grandchild{Old'Pa,Boy}", "child{Old'Pa,Daddy}", "grandson{Old'Pa,Boy}",
                "son{Old'Pa,Daddy}", "grandfather{Girl,Old'Pa}", "grandfather{Boy,Old'Pa}", "father{Daddy,Old'Pa}",
                "ancestor{Uncle,Old'Pa}", "sibling{Daddy,Uncle}", "father{Uncle,Old'Pa}", "child{Old'Pa,Uncle}",
                "brother{Uncle,Daddy}", "brother{Daddy,Uncle}", "descendent{Old'Pa,Uncle}", "niece{Uncle,Girl}",
                "nephew{Uncle,Boy}", "son{Old'Pa,Uncle}", "uncle{Girl,Uncle}", "uncle{Boy,Uncle}",
                "firstCousin{Girl,Cousin}", "firstCousin{Boy,Cousin}", "firstCousin{Cousin,Girl}", "firstCousin{Cousin,Boy}",
                "ancestor{Cousin,Uncle}", "ancestor{Cousin,Old'Pa}", "father{Cousin,Uncle}", "child{Uncle,Cousin}",
                "grandparent{Cousin,Old'Pa}", "uncle{Cousin,Daddy}", "descendent{Uncle,Cousin}", "descendent{Old'Pa,Cousin}",
                "aunt{Cousin,Mummy}", "grandchild{Old'Pa,Cousin}", "cousin{Cousin,Girl}", "cousin{Cousin,Boy}",
                "cousin{Girl,Cousin}", "cousin{Boy,Cousin}", "grandfather{Cousin,Old'Pa}", "daughter{Uncle,Cousin}",
                "granddaughter{Cousin,Old'Pa}", "niece{Daddy,Cousin}"
            };

              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

              	ie.LoadRuleBase(NewGedcomAdapter());
            Individual male = new Individual("M");
            Individual female = new Individual("F");
            Individual happyFamily = new Individual("Happy");
            Individual daddy = new Individual("Daddy");
            Individual mummy = new Individual("Mummy");
            Individual girl = new Individual("Girl");
            Individual boy = new Individual("Boy");

            ie.Assert(new Fact("sex", daddy, male));
            ie.Assert(new Fact("sex", mummy, female));
            ie.Assert(new Fact("sex", girl, female));
            ie.Assert(new Fact("sex", boy, male));

            ie.Assert(new Fact("spouseIn", daddy, happyFamily));
            ie.Assert(new Fact("spouseIn", mummy, happyFamily));
            ie.Assert(new Fact("childIn", girl, happyFamily));
            ie.Assert(new Fact("childIn", boy, happyFamily));
            Process();

            Assert.AreEqual(32, deducted, "(1) Deducted");
            Assert.IsFalse(wrongDeduction, "(1) Deductions OK");

            Individual oldpa = new Individual("Old'Pa");
            ie.Assert(new Fact("sex", oldpa, male));
            ie.Assert(new Fact("parent", daddy, oldpa));
            Process();

            Assert.AreEqual(17, deducted, "(2) Deducted");
            Assert.IsFalse(wrongDeduction, "(2) Deductions OK");

            Individual uncle = new Individual("Uncle");
            ie.Assert(new Fact("sex", uncle, male));
            ie.Assert(new Fact("parent", uncle, oldpa));
            ie.Assert(new Fact("sibling", uncle, daddy));
            Process();

            Assert.AreEqual(12, deducted, "(3) Deducted");
            Assert.IsFalse(wrongDeduction, "(3) Deductions OK");

            Individual cousin = new Individual("Cousin");
            ie.Assert(new Fact("sex", cousin, female));
            ie.Assert(new Fact("parent", cousin, uncle));
            Process();

            Assert.AreEqual(22, deducted, "(4) Deducted");
            Assert.IsFalse(wrongDeduction, "(4) Deductions OK");

            ie.NewFactHandler -= henf;
              	deductionsToCheck = null;
        }
コード例 #27
0
        public virtual void ExpressionAssertion()
        {
            ie.LoadRuleBase(NewTestAdapter());

            int a = 3;
            int b = 2;
            int result = a+5*b;

            Assert.IsTrue(ie.Assert(new Fact("expressionAssertionTrigger",
                                             new Individual(a),
                                             new Individual(b))), "Asserted trigger fact");

            deductionsToCheck = new string[] {"expressionAssertionResults{" + result + ",done}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;

            qrs = ie.RunQuery(new Query(new AtomGroup(AtomGroup.LogicalOperator.And,
                                                      new Atom("expressionAssertionResults", new Variable("result"), new Individual("done")))));
            Assert.AreEqual(1, qrs.Count, "Query Size");
            if (qrs.Count > 0) Assert.AreEqual(result, qrs[0][0].Members[0].Value, "Correct Typed Result");
        }
コード例 #28
0
ファイル: TestEngineMisc.cs プロジェクト: plamikcho/xbrlpoc
        public void DiscountVisio2003Pages()
        {
            deductionsToCheck = new string[]{"Customer Rating{Peter Miller,Premium}"};
              	NewFactEvent honf = new NewFactEvent(HandleOrderedNewFact);
              	ie.NewFactHandler += honf;

            ie.LoadRuleBase(new Visio2003Adapter(ruleFilesFolder + "discount.vdx",
                                                 FileAccess.Read,
                                                 "Customer Rules",
                                                 "Customer Data"));
            Process();
            Assert.AreEqual(1, deducted, "(1) Deducted");
            Assert.AreEqual(2, ie.FactsCount, "(2) Total Facts Count");
            Assert.IsFalse(wrongDeduction, "(3) Query Results");

              	ie.NewFactHandler -= honf;
              	deductionsToCheck = null;
        }
コード例 #29
0
        public virtual void ExpressionIndividualEvaluation()
        {
            ie.LoadRuleBase(NewTestAdapter());

            Assert.IsTrue(ie.Assert(new Fact("talking",
                                             new Individual("The Duke"),
                                             new Individual("hello world"))), "Asserted The Duke Details");

            Assert.IsTrue(ie.Assert(new Fact("talking",
                                             new Individual("Bobby Bob"),
                                             new Individual("what the?"))), "Asserted Bobby Bob Details");

            deductionsToCheck = new string[] {"education{The Duke,polite}"};
              	NewFactEvent henf = new NewFactEvent(HandleExpectedNewFact);
              	ie.NewFactHandler += henf;

            Process();

            Assert.AreEqual(1, deducted, "Deducted");
            Assert.IsFalse(wrongDeduction, "Wrong deduction");
            ie.NewFactHandler -= henf;
        }
コード例 #30
0
ファイル: IEGUIFacade.cs プロジェクト: Ghasan/NxBRE
        public void Process(NewFactEvent nfh, NewFactEvent dfh, NewFactEvent mfh)
        {
            ie.NewFactHandler += nfh;
            ie.DeleteFactHandler += dfh;
            ie.ModifyFactHandler += mfh;

            if (ie.BinderType != null) ie.Process(new Hashtable());
            else ie.Process();

            ie.DeleteFactHandler -= dfh;
            ie.NewFactHandler -= nfh;
        }