Пример #1
0
 public void TestGetMatchesBySubjectPredicateObject()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T1, T2, T3, T4, T5, T6 });
     Assert.AreEqual(2, c.GetMatches("http://example.org/s", "http://example.org/p", "http://example.org/o").Count());
     Assert.AreEqual(1, c.GetMatches("http://example.org/s1", "http://example.org/p", "http://example.org/o").Count());
     Assert.AreEqual(0, c.GetMatches("http://example.org/s1", "http://example.org/p1", "http://example.org/o1").Count());
 }
Пример #2
0
        public void TestGetMatchesWithDifferentTriplePatterns()
        {
            var c = new TripleCollection();
            c.AddRange(new []{T1, T2, T3, T4, T5, T6});
            Assert.AreEqual(1, c.GetMatches(new Triple{Subject = "http://example.org/s", Predicate = "http://example.org/p", Object = "http://example.org/o", Graph = Constants.DefaultGraphUri}).Count(),
                "Expected 1 match with fully-specified pattern");
            Assert.AreEqual(2, c.GetMatches(new Triple{Subject = "http://example.org/s", Predicate = "http://example.org/p", Object = "http://example.org/o", Graph = null}).Count(),
                "Expected two matches with graph wildcard.");
            // With Triple.Match an object wildcard matches literals and non-literals alike
            Assert.AreEqual(3, c.GetMatches(new Triple { Subject = "http://example.org/s", Predicate = "http://example.org/p", Object = null, Graph = Constants.DefaultGraphUri }).Count(),
                "Expected 3 matches with object wildcard");
            Assert.AreEqual(2, c.GetMatches(new Triple { Subject = "http://example.org/s", Predicate = null, Object = "http://example.org/o", Graph = Constants.DefaultGraphUri }).Count(),
                "Expected 2 matches with predicate wildcard");
            Assert.AreEqual(2, c.GetMatches(new Triple { Subject = null, Predicate = "http://example.org/p", Object = "http://example.org/o", Graph = Constants.DefaultGraphUri }).Count(),
                "Expected 2 matches with subject wildcard");

        }