Example #1
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");
        }
Example #2
0
        public void TestGetMatchesBySubject()
        {
            var c = new TripleCollection();

            c.AddRange(new[] { T1, T2, T3, T4, T5, T6 });
            Assert.AreEqual(5, c.GetMatches("http://example.org/s").Count());
            Assert.AreEqual(1, c.GetMatches("http://example.org/s1").Count());
        }