コード例 #1
0
        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));
        }
コード例 #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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void Remove_requires_key()
        {
            var d = new DynamicGraph();

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Remove(null as Uri));
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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)));
        }
コード例 #8
0
        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);
        }
コード例 #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));
        }
コード例 #10
0
        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);
        }
コード例 #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);
        }
コード例 #12
0
        public void Remove_po_rejects_null_subject()
        {
            var d = new DynamicGraph();

            Assert.False(d.Remove(null as INode, null));
        }
コード例 #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)));
        }
コード例 #14
0
        public void Remove_rejects_null_key()
        {
            var d = new DynamicGraph();

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