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);
}
}