Beispiel #1
0
        public void Contains()
        {
            TripleStore store = MakeNewTripleStore();


            store.Add(new Statement(new UriRef("ex:subj"), new UriRef("ex:pred"), new UriRef("ex:obj")));

            Assert.IsTrue(store.Contains(new Statement(new UriRef("ex:subj"), new UriRef("ex:pred"), new UriRef("ex:obj"))));
            store.Clear();
        }
Beispiel #2
0
        public void EvaluateRule()
        {
            TripleStore store = MakeNewTripleStore();

            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 consequent");
            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");

            store.Clear();
        }