Exemplo n.º 1
0
        public void allAntecedentMatchesAreProcessed()
        {
            TripleStore store = new MemoryTripleStore();

            SimpleRuleProcessor ruleProcessor = new SimpleRuleProcessor();

            store.Add(new Statement(new UriRef("http://example.com/subj1"), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj1")));
            store.Add(new Statement(new UriRef("http://example.com/subj2"), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj2")));

            Rule rule = new Rule();

            rule.AddAntecedent(new Pattern(new Variable("var1"), new UriRef("http://example.com/pred"), new Variable("var2")));
            rule.AddConsequent(new Pattern(new Variable("var1"), new UriRef("http://example.com/newPred"), new Variable("var2")));

            ruleProcessor.Process(rule, store);

            Assert.IsFalse(store.IsEmpty(), "Destination is non-empty");

            Assert.IsTrue(store.Contains(new Statement(new UriRef("http://example.com/subj1"), new UriRef("http://example.com/newPred"), new UriRef("http://example.com/obj1"))), "Destination contains first match onsequent");
            Assert.IsTrue(store.Contains(new Statement(new UriRef("http://example.com/subj2"), new UriRef("http://example.com/newPred"), new UriRef("http://example.com/obj2"))), "Destination contains second match consequent");
        }
Exemplo n.º 2
0
        public void noAntecedentsAutomaticallyAddsConsequents()
        {
            TripleStore store = new MemoryTripleStore();

            SimpleRuleProcessor ruleProcessor = new SimpleRuleProcessor();

            Rule rule = new Rule();

            rule.AddConsequent(new Pattern(new UriRef("http://example.com/subj"), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj")));

            ruleProcessor.Process(rule, store);

            Assert.IsFalse(store.IsEmpty(), "Store is non-empty");

            Assert.IsTrue(store.Contains(new Statement(new UriRef("http://example.com/subj"), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj"))), "Destination contains consequent");
        }
Exemplo n.º 3
0
        public void consequentsAreAddedUsingAntecedentSolutionBindings()
        {
            TripleStore store = new MemoryTripleStore();

            SimpleRuleProcessor ruleProcessor = new SimpleRuleProcessor();

            store.Add(new Statement(new UriRef("http://example.com/subj"), new UriRef("http://example.com/pred"), new UriRef("http://example.com/obj")));

            Rule rule = new Rule();

            rule.AddAntecedent(new Pattern(new Variable("var1"), new UriRef("http://example.com/pred"), new Variable("var2")));
            rule.AddConsequent(new Pattern(new Variable("var1"), new UriRef("http://example.com/newPred"), new Variable("var2")));

            ruleProcessor.Process(rule, store);

            Assert.IsFalse(store.IsEmpty(), "Destination is non-empty");

            Assert.IsTrue(store.Contains(new Statement(new UriRef("http://example.com/subj"), new UriRef("http://example.com/newPred"), new UriRef("http://example.com/obj"))), "Destination contains consequent");
        }