public void ExecuteXmlReturnsSparqlResultsFormatXml() { TripleStore store = new MemoryTripleStore(); store.Add(new Statement(new UriRef("http://example.com/subj"), new UriRef("http://example.com/property"), new UriRef("http://example.com/obj"))); SparqlQuery query = new SparqlQuery("SELECT ?var WHERE { <http://example.com/subj> <http://example.com/property> ?var }"); XmlDocument resultsRaw = query.ExecuteXml(store); XmlDocument resultsCanonical = new XmlDocument(); resultsCanonical.LoadXml(resultsRaw.InnerXml); XmlDocument expected = new XmlDocument(); expected.LoadXml(@"<sparql xmlns=""http://www.w3.org/2005/sparql-results#""> <head> <variable name=""var""/> </head> <results ordered=""false"" distinct=""false""> <result> <binding name=""var""><uri>http://example.com/obj</uri></binding> </result> </results> </sparql>"); Assert.AreEqual(expected.InnerXml, resultsCanonical.InnerXml, "Result of query should equal expected XML"); }
public void ExecuteXmlPassesSelectQueryToTripleStore() { SparqlQuery query = new SparqlQuery("SELECT ?var WHERE { <http://example.com/subject> <http://example.com/predicate> ?var }"); TripleStoreStore store = new TripleStoreStore(); XmlDocument results = query.ExecuteXml(store); Assert.IsTrue(store.WasSolveCalledWith(query), "Query should invoke triple store's solve method"); }