public void Remove_reports_retraction_success()
        {
            var d = new DynamicGraph();

            d.LoadFromString("<urn:s> <urn:p> <urn:o> .");

            var s = UriFactory.Create("urn:s");

            Assert.True(d.Remove(s));
            Assert.False(d.Remove(s));
        }
Example #2
0
        public void Remove_p_reports_retraction_success()
        {
            var d = new DynamicGraph();

            d.LoadFromString("<urn:s> <urn:p> <urn:o> .");

            var s = d.Nodes.First();

            Assert.True(d.Remove(s));
            Assert.False(d.Remove(s));
        }
        public void Remove_retracts_by_subject()
        {
            var expected = new Graph();

            expected.LoadFromString(@"
<urn:s2> <urn:s1> ""o5"" .
<urn:s2> <urn:p3> <urn:s1> .
");

            var actual = new DynamicGraph();

            actual.LoadFromString(@"
<urn:s1> <urn:p1> ""o1"" .
<urn:s1> <urn:p1> ""o2"" .
<urn:s1> <urn:p2> ""o3"" .
<urn:s1> <urn:p2> ""o4"" .
<urn:s2> <urn:s1> ""o5"" .
<urn:s2> <urn:p3> <urn:s1> .
");

            var s1 = UriFactory.Create("urn:s1");

            actual.Remove(s1);

            Assert.Equal <IGraph>(expected, actual);
        }
        public void Remove_requires_key()
        {
            var d = new DynamicGraph();

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Remove(null as Uri));
        }
Example #5
0
        public void Remove_po_handles_public_properties()
        {
            var expected = new Graph();

            expected.LoadFromString(@"
<urn:s2> <urn:s1> ""o3"" .
<urn:s2> <urn:p3> <urn:s1> .
");

            var actual = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));

            actual.LoadFromString(@"
<urn:s1> <urn:p1> ""o1"" .
<urn:s1> <urn:p2> ""o2"" .
<urn:s2> <urn:s1> ""o3"" .
<urn:s2> <urn:p3> <urn:s1> .
");

            var s1 = actual.Nodes.First();
            var predicateAndObjects = new
            {
                p1 = "o1",
                p2 = "o2"
            };

            actual.Remove(s1, predicateAndObjects);

            Assert.Equal <IGraph>(expected, actual);
        }
Example #6
0
        public void Remove_po_rejects_null_predicate_and_object()
        {
            var d = new DynamicGraph();
            var s = d.CreateBlankNode();

            Assert.False(d.Remove(s, null));
        }
Example #7
0
        public void Remove_pair_ignores_missing_statements()
        {
            var d = new DynamicGraph() as IDictionary <string, object>;
            var s = "urn:s";

            Assert.False(d.Remove(new KeyValuePair <string, object>(s, null)));
        }
        public void Remove_pair_requires_key()
        {
            var d = new DynamicGraph() as IDictionary <Uri, object>;

            var condition = d.Remove(new KeyValuePair <Uri, object>(null, null));

            Assert.False(condition);
        }
Example #9
0
        public void Remove_po_rejects_missing_statements()
        {
            var d = new DynamicGraph();
            var s = d.CreateBlankNode();
            var p = d.CreateBlankNode();

            Assert.False(d.Remove(s, p));
        }
        public void Remove_pair_ignores_missing_statements()
        {
            var d = new DynamicGraph() as IDictionary <Uri, object>;
            var s = UriFactory.Create("urn:s");

            var condition = d.Remove(new KeyValuePair <Uri, object>(s, null));

            Assert.False(condition);
        }
Example #11
0
        public void Remove_po_handles_dictionaries()
        {
            var expected = new Graph();

            expected.LoadFromString(@"
# <urn:s> <urn:s> <urn:s> .
<urn:s> <urn:s> <urn:p> .
<urn:s> <urn:s> <urn:o> .
<urn:s> <urn:p> <urn:s> .
# <urn:s> <urn:p> <urn:p> .
<urn:s> <urn:p> <urn:o> .
<urn:s> <urn:o> <urn:s> .
<urn:s> <urn:o> <urn:p> .
# <urn:s> <urn:o> <urn:o> .
<urn:p> <urn:s> <urn:s> .
<urn:p> <urn:s> <urn:p> .
<urn:p> <urn:s> <urn:o> .
<urn:p> <urn:p> <urn:s> .
<urn:p> <urn:p> <urn:p> .
<urn:p> <urn:p> <urn:o> .
<urn:p> <urn:o> <urn:s> .
<urn:p> <urn:o> <urn:p> .
<urn:p> <urn:o> <urn:o> .
<urn:o> <urn:s> <urn:s> .
<urn:o> <urn:s> <urn:p> .
<urn:o> <urn:s> <urn:o> .
<urn:o> <urn:p> <urn:s> .
<urn:o> <urn:p> <urn:p> .
<urn:o> <urn:p> <urn:o> .
<urn:o> <urn:o> <urn:s> .
<urn:o> <urn:o> <urn:p> .
<urn:o> <urn:o> <urn:o> .
");

            var actual = new DynamicGraph();

            actual.LoadFromString(@"
<urn:s> <urn:s> <urn:s> . # should retract
<urn:s> <urn:s> <urn:p> .
<urn:s> <urn:s> <urn:o> .
<urn:s> <urn:p> <urn:s> .
<urn:s> <urn:p> <urn:p> . # should retract
<urn:s> <urn:p> <urn:o> .
<urn:s> <urn:o> <urn:s> .
<urn:s> <urn:o> <urn:p> .
<urn:s> <urn:o> <urn:o> . # should retract
<urn:p> <urn:s> <urn:s> .
<urn:p> <urn:s> <urn:p> .
<urn:p> <urn:s> <urn:o> .
<urn:p> <urn:p> <urn:s> .
<urn:p> <urn:p> <urn:p> .
<urn:p> <urn:p> <urn:o> .
<urn:p> <urn:o> <urn:s> .
<urn:p> <urn:o> <urn:p> .
<urn:p> <urn:o> <urn:o> .
<urn:o> <urn:s> <urn:s> .
<urn:o> <urn:s> <urn:p> .
<urn:o> <urn:s> <urn:o> .
<urn:o> <urn:p> <urn:s> .
<urn:o> <urn:p> <urn:p> .
<urn:o> <urn:p> <urn:o> .
<urn:o> <urn:o> <urn:s> .
<urn:o> <urn:o> <urn:p> .
<urn:o> <urn:o> <urn:o> .
");

            var s = actual.CreateUriNode(UriFactory.Create("urn:s"));
            var p = actual.CreateUriNode(UriFactory.Create("urn:p"));
            var o = actual.CreateUriNode(UriFactory.Create("urn:o"));
            var predicateAndObjects = new Dictionary <object, object>
            {
                { s, s },
                { p.Uri, p },
                { o.Uri.AbsoluteUri, o }
            };

            actual.Remove(s, predicateAndObjects);

            Assert.Equal <IGraph>(expected, actual);
        }
Example #12
0
        public void Remove_po_rejects_null_subject()
        {
            var d = new DynamicGraph();

            Assert.False(d.Remove(null as INode, null));
        }
Example #13
0
        public void Remove_pair_requires_key()
        {
            var d = new DynamicGraph() as IDictionary <string, object>;

            Assert.False(d.Remove(new KeyValuePair <string, object>(null, null)));
        }
Example #14
0
        public void Remove_rejects_null_key()
        {
            var d = new DynamicGraph();

            Assert.False(d.Remove(null as string));
        }