예제 #1
0
        public void Enumerates_dynamic_results()
        {
            var g = new Graph();

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

            var results = (SparqlResultSet)g.ExecuteQuery(@"SELECT * WHERE { ?s ?p ?o }");
            var d       = new DynamicSparqlResultSet(results);

            foreach (var x in d)
            {
                Assert.NotNull(x);
            }
        }
예제 #2
0
        public void Provides_enumerable_meta_object()
        {
            var g = new Graph();

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

            var results = (SparqlResultSet)g.ExecuteQuery(@"SELECT * WHERE { ?s ?p ?o }");
            var d       = new DynamicSparqlResultSet(results);

            var p  = (IDynamicMetaObjectProvider)d;
            var mo = p.GetMetaObject(Expression.Empty());

            Assert.NotNull(mo);
            Assert.IsType <EnumerableMetaObject>(mo);
        }
        public void Converts_bindings_to_native_datatypes()
        {
            var g = new Graph();

            g.LoadFromString(@"
@prefix : <urn:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:s
    :p
        :x ,
        _:blank ,
        0E0 ,
        ""0""^^xsd:float ,
        0.0 ,
        false ,
        ""1900-01-01""^^xsd:dateTime ,
        ""P1D""^^xsd:duration ,
        0 ,
        """" ,
        """"^^:datatype ,
        """"@en .
");

            var results = (SparqlResultSet)g.ExecuteQuery(@"
SELECT ?o
WHERE {
    ?s ?p ?o .
}
");

            var d = new DynamicSparqlResultSet(results);

            Assert.Collection(
                d,
                item => Assert.IsType <Uri>(item["o"]),
                item => Assert.IsAssignableFrom <IBlankNode>(item["o"]),
                item => Assert.IsType <double>(item["o"]),
                item => Assert.IsType <float>(item["o"]),
                item => Assert.IsType <decimal>(item["o"]),
                item => Assert.IsType <bool>(item["o"]),
                item => Assert.IsType <DateTimeOffset>(item["o"]),
                item => Assert.IsType <TimeSpan>(item["o"]),
                item => Assert.IsType <long>(item["o"]),
                item => Assert.IsType <string>(item["o"]),
                item => Assert.IsAssignableFrom <ILiteralNode>(item["o"]),
                item => Assert.IsAssignableFrom <ILiteralNode>(item["o"]));
        }