Esempio n. 1
0
        public void Add_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> .
");

            var d = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));
            var s = d.CreateUriNode(UriFactory.Create("urn:s"));
            var p = d.CreateUriNode(UriFactory.Create("urn:p"));
            var o = d.CreateUriNode(UriFactory.Create("urn:o"));
            var predicateAndObjects = new Dictionary <object, object>
            {
                { "s", new[] { s, p, o } },
                { new Uri("urn:p"), new[] { s, p, o } },
                { d.CreateUriNode(new Uri("urn:o")), new[] { s, p, o } }
            };

            d.Add(s, predicateAndObjects);

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

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Add(null as Uri, null));
        }
Esempio n. 3
0
        public void Add_handles_public_properties()
        {
            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> .
");

            var d = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));
            var s = d.CreateUriNode(UriFactory.Create("urn:s"));
            var p = d.CreateUriNode(UriFactory.Create("urn:p"));
            var o = d.CreateUriNode(UriFactory.Create("urn:o"));
            var predicateAndObjects = new
            {
                s = new[] { s, p, o },
                p = new[] { s, p, o },
                o = new[] { s, p, o },
            };

            d.Add(s, predicateAndObjects);

            Assert.Equal <IGraph>(expected, d);
        }
Esempio n. 4
0
        public void Add_requires_subject()
        {
            var d = new DynamicGraph();

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Add(null as INode, null));
        }
        public void Add_requires_value()
        {
            var d = new DynamicGraph();
            var s = UriFactory.Create("urn:s");

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Add(s, null));
        }
Esempio n. 6
0
        public void Add_requires_value()
        {
            var d = new DynamicGraph();
            var s = d.CreateBlankNode();

            Assert.Throws <ArgumentNullException>(() =>
                                                  d.Add(s, null));
        }
Esempio n. 7
0
        public void Add_fails_unknown_key_type()
        {
            var g = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));
            var s = g.CreateBlankNode();
            var predicateAndObjects = new Dictionary <object, object>
            {
                { 0, "o" }
            };

            Assert.Throws <InvalidOperationException>(() =>
                                                      g.Add(s, predicateAndObjects));
        }
Esempio n. 8
0
        public void Add_handles_foreign_nodes()
        {
            var expected = new Graph();

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

            var d = new DynamicGraph(subjectBaseUri: UriFactory.Create("urn:"));
            var s = expected.CreateUriNode(UriFactory.Create("urn:s"));
            var o = expected.CreateUriNode(UriFactory.Create("urn:o"));

            d.Add(s, new { p = o });

            Assert.Equal <IGraph>(expected, d);
        }
        public void Add_handles_dictionaries()
        {
            var actual = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));
            var s      = UriFactory.Create("urn:s");

            var expected = new Graph();

            expected.LoadFromString(@"
<urn:s> <urn:p1> ""o1"" .
<urn:s> <urn:p2> ""o2"" .
");

            var predicateAndObjects = new Dictionary <object, object>
            {
                { "p1", "o1" },
                { "p2", "o2" }
            };

            actual.Add(s, predicateAndObjects);

            Assert.Equal <IGraph>(expected, actual);
        }
        public void Add_handles_public_properties()
        {
            var actual = new DynamicGraph(predicateBaseUri: UriFactory.Create("urn:"));
            var s      = UriFactory.Create("urn:s");

            var expected = new Graph();

            expected.LoadFromString(@"
<urn:s> <urn:p1> ""o1"" .
<urn:s> <urn:p2> ""o2"" .
");

            var predicateAndObjects = new
            {
                p1 = "o1",
                p2 = "o2"
            };

            actual.Add(s, predicateAndObjects);

            Assert.Equal <IGraph>(expected, actual);
        }