public void Converts_native_data_types() { var expected = new Graph(); expected.LoadFromString(@" @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix : <urn:> . :s :p _:o , :o , true , ""255""^^xsd:unsignedByte , ""9999-12-31T23:59:59.999999""^^xsd:dateTime , ""9999-12-31T23:59:59.999999+00:00""^^xsd:dateTime , ""79228162514264337593543950335""^^xsd:decimal , ""1.797E+308""^^xsd:double , ""3.402E+38""^^xsd:float , ""9223372036854775807""^^xsd:integer , ""2147483647""^^xsd:integer , """" , ""\uFFFF"" , ""P10675199DT2H48M5.4775807S""^^xsd:duration . "); var d = new DynamicGraph { BaseUri = UriFactory.Create("urn:") }; d["s"] = new { p = new object[] { new NodeFactory().CreateBlankNode("o"), UriFactory.Create("urn:o"), true, byte.MaxValue, DateTime.MaxValue, DateTimeOffset.MaxValue, decimal.MaxValue, 1.797e308, 3.402e38f, long.MaxValue, int.MaxValue, string.Empty, char.MaxValue, TimeSpan.MaxValue } }; TestTools.CompareGraphs(expected, d, true); //Assert.Equal<IGraph>(expected, d); }
public void StorageVirtuosoBlankNodePersistence() { //Create our Test Graph Graph g = new Graph(); g.BaseUri = new Uri("http://example.org/bnodes/"); g.NamespaceMap.AddNamespace(String.Empty, g.BaseUri); IBlankNode b = g.CreateBlankNode("blank"); IUriNode rdfType = g.CreateUriNode("rdf:type"); IUriNode bnode = g.CreateUriNode(":BlankNode"); g.Assert(new Triple(b, rdfType, bnode)); Assert.AreEqual(1, g.Triples.Count, "Should only be 1 Triple in the Test Graph"); //Connect to Virtuoso VirtuosoManager manager = VirtuosoTest.GetConnection(); try { //Save Graph manager.SaveGraph(g); //Retrieve Graph h = new Graph(); Graph i = new Graph(); manager.LoadGraph(h, g.BaseUri); manager.LoadGraph(i, g.BaseUri); Assert.AreEqual(1, h.Triples.Count, "Retrieved Graph should only contain 1 Triple"); Assert.AreEqual(1, i.Triples.Count, "Retrieved Graph should only contain 1 Triple"); Console.WriteLine("Contents of Retrieved Graph:"); foreach (Triple t in h.Triples) { Console.WriteLine(t.ToString()); } Console.WriteLine(); TestTools.CompareGraphs(h, i, true); //Save back again manager.SaveGraph(h); //Retrieve again Graph j = new Graph(); manager.LoadGraph(j, g.BaseUri); Console.WriteLine("Contents of Retrieved Graph (Retrieved after saving original Retrieval):"); foreach (Triple t in j.Triples) { Console.WriteLine(t.ToString()); } Console.WriteLine(); TestTools.CompareGraphs(h, j, false); TestTools.CompareGraphs(i, j, false); //Save back yet again manager.SaveGraph(j); //Retrieve yet again Graph k = new Graph(); manager.LoadGraph(k, g.BaseUri); Console.WriteLine("Contents of Retrieved Graph (Retrieved after saving second Retrieval):"); foreach (Triple t in k.Triples) { Console.WriteLine(t.ToString()); } Console.WriteLine(); TestTools.CompareGraphs(j, k, false); } finally { if (manager != null) { manager.Dispose(); } } }