public void BrightstarGetUpdateFunction() { string storeName = null; try { storeName = "UpdStore_" + Guid.NewGuid(); brightstarConnector = new Connector("type=embedded;storesdirectory=brightstar;storename=" + storeName); brightstarConnector.Client.CreateStore(storeName); var updFunc = brightstarConnector.GetUpdateFunction(); var queryFunc = brightstarConnector.GetQueryingFunction(); var dyno = DynamicSPARQL.CreateDyno(queryingFunc: queryFunc, updateFunc: updFunc, autoquotation: false); var updres = dyno.Insert( prefixes: new[] { SPARQL.Prefix("dc", "http://purl.org/dc/elements/1.1/") }, insert: SPARQL.Triple(s: "<http://example/book1>", p: new[] { @"dc:title ""David Copperfield""@fr", @"dc:creator ""Edmund Wells""", "dc:price 42"}) ); ((IJobInfo)updres).JobCompletedOk.Should().Be.True(); IEnumerable<dynamic> res = dyno.Select( projection: "?s ?p ?o", where: SPARQL.Triple("?s ?p ?o") ); var list = res.ToList(); list.Count.Should().Equal(3); list.Where(x => x.p == "price" && x.o == 42).Count().Should().Equal(1); list.Where(x => x.p == "title" && x.o == "David Copperfield").Count().Should().Equal(1); list.Where(x => x.p == "creator" && x.o == "Edmund Wells").Count().Should().Equal(1); dyno.Delete( where: SPARQL.Triple(s: "<http://example/book1>", p: "?property ?value" ) ); res = dyno.Select( projection: "?s ?p ?o", where: SPARQL.Triple("?s ?p ?o") ); res.ToList().Count.Should().Equal(0); } finally { if (brightstarConnector.Client != null) brightstarConnector.Client.DeleteStore(brightstarConnector.StoreName); } }
public void BrightstarConnectorTest() { string storeName = null; try { storeName = GenerateTestStore(); brightstarConnector = new Connector("type=embedded;storesdirectory=brightstar;storename=" + storeName); var func = brightstarConnector.GetQueryingFunction(); var dyno = DynamicSPARQL.CreateDyno(func, autoquotation: true); IEnumerable<dynamic> list = dyno.Select( projection: "?product ?p ?o ?level", where: SPARQL.Group( SPARQL.Triple("?product ?p ?o"), SPARQL.Optional( @"?product ""http://www.brightstardb.com/schemas/product/level"" ?level" ) ) ); var resultList = list.ToList(); IList<string> result = resultList.Select(triple => (string)triple.o).ToList(); result.Should().Contain.One("nosql"); result.Should().Contain.One(".net"); result.Should().Contain.One("rdf"); ((object)resultList.First().level).Should().Be.Null(); } catch(Exception exc) { throw exc; } finally { if (brightstarConnector.Client!=null) brightstarConnector.Client.DeleteStore(brightstarConnector.StoreName); } }