public void StorageDydraSaveToDefaultGraph() { try { Options.HttpDebugging = true; Graph orig = new Graph(); orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); orig.BaseUri = null; DydraConnector dydra = DydraTests.GetConnection(); dydra.SaveGraph(orig); Graph g = new Graph(); dydra.LoadGraph(g, (Uri)null); if (orig.Triples.Count == g.Triples.Count) { Assert.AreEqual(orig, g, "Graphs should be equal"); } else { Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph"); } } finally { Options.HttpFullDebugging = false; Options.HttpDebugging = false; } }
public void StorageDydraRemoveTriples() { try { Options.HttpDebugging = true; DydraConnector dydra = DydraTests.GetConnection(); Graph g = new Graph(); g.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); g.BaseUri = new Uri("http://example.org/storage/dydra/update/remove"); dydra.SaveGraph(g); List <Triple> ts = new List <Triple>(); ts.Add(new Triple(g.CreateUriNode(new Uri("http://example.org/subject")), g.CreateUriNode(new Uri("http://example.org/predicate")), g.CreateUriNode(new Uri("http://example.org/object")))); dydra.UpdateGraph(g.BaseUri, null, ts); g = new Graph(); dydra.LoadGraph(g, "http://example.org/storage/dydra/update/remove"); Assert.IsTrue(ts.All(t => !g.ContainsTriple(t)), "Removed Triple should be in the Graph"); } finally { Options.HttpDebugging = false; } }
public void StorageDydraDeleteGraph() { try { Options.HttpDebugging = true; Graph orig = new Graph(); orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); orig.BaseUri = new Uri("http://example.org/storage/dydra/delete"); DydraConnector dydra = DydraTests.GetConnection(); dydra.SaveGraph(orig); Graph g = new Graph(); dydra.LoadGraph(g, orig.BaseUri); if (orig.Triples.Count == g.Triples.Count) { GraphDiffReport report = orig.Difference(g); if (!report.AreEqual) { TestTools.ShowDifferences(report); } Assert.AreEqual(orig, g, "Graphs should be equal"); } else { Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph"); } //Now delete the Graph dydra.DeleteGraph(orig.BaseUri); //And retrieve it again g = new Graph(); dydra.LoadGraph(g, orig.BaseUri); Assert.IsTrue(g.IsEmpty, "Graph should be empty as was deleted from repository"); Assert.AreNotEqual(orig, g, "Graphs should not be equal"); } finally { Options.HttpDebugging = false; } }
public void StorageDydraSaveToNamedGraph() { try { Options.HttpDebugging = true; Graph orig = new Graph(); orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); orig.BaseUri = new Uri("http://example.org/storage/dydra/save/named/"); DydraConnector dydra = DydraTests.GetConnection(); dydra.SaveGraph(orig); Graph g = new Graph(); dydra.LoadGraph(g, orig.BaseUri); if (orig.Triples.Count == g.Triples.Count) { GraphDiffReport report = orig.Difference(g); if (!report.AreEqual) { TestTools.ShowDifferences(report); } Assert.AreEqual(orig, g, "Graphs should be equal"); } else { Assert.IsTrue(g.HasSubGraph(orig), "Original Graph should be a sub-graph of retrieved Graph"); } } finally { Options.HttpFullDebugging = false; Options.HttpDebugging = false; } }
public void StorageDydraLoadGraphWithHandler() { try { Options.HttpDebugging = true; Graph orig = new Graph(); orig.LoadFromEmbeddedResource("VDS.RDF.Configuration.configuration.ttl"); orig.BaseUri = new Uri("http://example.org/storage/dydra/tests/counting"); DydraConnector dydra = DydraTests.GetConnection(); dydra.DeleteGraph(orig.BaseUri); dydra.SaveGraph(orig); CountHandler handler = new CountHandler(); dydra.LoadGraph(handler, orig.BaseUri); Assert.AreEqual(orig.Triples.Count, handler.Count, "Triple Counts should be equal"); } finally { Options.HttpDebugging = false; } }