public void Values_are_native_bindings() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Equal(result.Select(pair => ((IUriNode)pair.Value).Uri), d.Values.Cast <Uri>()); }
public void Get_index_returns_native_binding() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Equal(UriFactory.Create("urn:s"), d["s"]); }
public void ContainsKey_matches_variable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.True(d.ContainsKey("s")); }
public void Contains_matches_native_binding() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Contains(new KeyValuePair <string, object>("s", UriFactory.Create("urn:s")), d); }
public void Contains_rejects_missing_variable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.DoesNotContain(new KeyValuePair <string, object>("x", null), d); }
public void Is_writable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.False(d.IsReadOnly); }
public void Counts_bound_variables() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Equal(result.Count, d.Count); }
public void Set_index_requires_variable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Throws <ArgumentNullException>(() => d[null] = null); }
public void Add_binds_variable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); d.Add("x", "y"); Assert.Equal("y", ((ILiteralNode)result["x"]).Value); }
public void Clear_unbinds_all_variables() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); d.Clear(); Assert.Empty(result); }
public void Converts_unbound_variables_to_null() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT ?x WHERE { ?s ?p ?o . VALUES ?x { UNDEF } } "); var result = results.Single(); var d = new DynamicSparqlResult(result); Assert.Null(d["x"]); }
public void Set_index_binds_variable() { var g = new Graph(); g.LoadFromString(@" <urn:s> <urn:p> <urn:o> . "); var results = (SparqlResultSet)g.ExecuteQuery(@" SELECT * WHERE { ?s ?p ?o . } "); var result = results.Single(); var d = new DynamicSparqlResult(result); var s2 = UriFactory.Create("urn:s2"); var expected = new NodeFactory().CreateUriNode(s2); d["s"] = s2; Assert.Equal(expected, result["s"]); }