public void TestAddUpdatesCollection()
 {
     var c = new TripleCollection();
     c.Add(T1);
     Assert.AreEqual(1, c.Count());
     Assert.IsTrue(c.Items.Any(x=>x.Equals(T1)));
 }
 public void TestAddRangeUpdatesCollection()
 {
     var c = new TripleCollection();
     c.AddRange(new []{T1, T2, T3});
     Assert.AreEqual(3, c.Count());
     Assert.IsTrue(c.Items.Any(x=>x.Equals(T1)));
     Assert.IsTrue(c.Items.Any(x => x.Equals(T2)));
     Assert.IsTrue(c.Items.Any(x => x.Equals(T3)));
 }
 public void TestAddRaisesArgumentNullException()
 {
     var c = new TripleCollection();
     c.Add(null);
 }
 public void TestContainsSubject()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T1, T2, T3, T4, T5, T6 });
     Assert.IsTrue(c.ContainsSubject("http://example.org/s"));
     Assert.IsTrue(c.ContainsSubject("http://example.org/s1"));
     Assert.IsFalse(c.ContainsSubject("http://example.org/p"));
 }
 public void TestEnumerateTriples()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T1, T2, T3, T4, T5, T6 });
     var triples = c.Items.ToList();
     Assert.AreEqual(6, triples.Count);
     Assert.Contains(T1, triples);
     Assert.Contains(T2, triples);
     Assert.Contains(T3, triples);
     Assert.Contains(T4, triples);
     Assert.Contains(T5, triples);
     Assert.Contains(T6, triples);
 }
 public void TestClearRemovesAllTriples()
 {
     var c = new TripleCollection();
     c.AddRange(new[] {T1, T2, T3, T4, T5, T6});
     var triples = c.Items.ToList();
     Assert.AreEqual(6, triples.Count);
     c.Clear();
     Assert.AreEqual(0, c.Items.Count());
     triples = c.Items.ToList();
     Assert.AreEqual(0, triples.Count);
 }
 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());
 }
 public void TestEnumerateSubjects()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T1, T2, T3, T4, T5, T6 });
     var subjects = c.Subjects.ToList();
     Assert.AreEqual(2, subjects.Count);
     Assert.Contains("http://example.org/s", subjects);
     Assert.Contains("http://example.org/s1", subjects);
 }
        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");

        }
 public void TestRemoveByObjectDoesNotRemoveLiteralMatches()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T2, T3 });
     c.RemoveByObject("http://example.org/o");
     Assert.AreEqual(1, c.Count());
     Assert.IsTrue(c.Items.Any(x => x.Equals(T3)));
 }
 public void TestRemoveBySubjectPredicateLiteralDoesNotRemoveUriMatches()
 {
     var c = new TripleCollection();
     c.AddRange(new[] { T2, T3 });
     c.RemoveBySubjectPredicateLiteral("http://example.org/s", "http://example.org/p", "http://example.org/o", RdfDatatypes.String, null);
     Assert.AreEqual(1, c.Count());
     Assert.IsTrue(c.Items.Any(x => x.Equals(T2)));
 }
 public void TestRemoveBySubjectPredicateRemoveAllMatches()
 {
     var c = new TripleCollection();
     c.AddRange(new []{T1, T5});
     Assert.AreEqual(2, c.Count());
     c.RemoveBySubjectPredicate("http://example.org/s", "http://example.org/p1");
     Assert.AreEqual(1, c.Count());
     Assert.IsTrue(c.Items.Any(x=>x.Equals(T1)));
 }
 public void TestRemoveBySubjectRemovesAllMatches()
 {
     var c = new TripleCollection();
     c.AddRange(new []{T1, T2, T3, T4});
     Assert.AreEqual(4, c.Count());
     c.RemoveBySubject("http://example.org/s");
     Assert.AreEqual(1, c.Count());
     Assert.IsTrue(c.Items.Any(x=>x.Equals(T4)));
 }