Skip to content

Commit

Permalink
Added missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco De Salvo committed May 27, 2024
1 parent 947987a commit ffe6d2c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions RDFSharp.Test/Store/Engines/RDFMemoryStoreTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,28 @@ public async Task ShouldImportFromDataTableAsync()
Assert.IsTrue(store2.Equals(store1));
}

[TestMethod]
public async Task ShouldImportFromDataTableAsyncWithEnabledDatatypeDiscovery()
{
RDFMemoryStore store1 = new RDFMemoryStore();
RDFQuadruple quadruple1 = new RDFQuadruple(new RDFContext("http://ctx/"), new RDFResource("http://subj/"), new RDFResource("http://pred/"), new RDFPlainLiteral("lit", "en-US"));
RDFQuadruple quadruple2 = new RDFQuadruple(new RDFContext("http://ctx/"), new RDFResource("http://subj/"), new RDFResource("http://pred/"), new RDFResource("http://obj/"));
store1.AddQuadruple(quadruple1)
.AddQuadruple(quadruple2)
.MergeGraph(new RDFGraph()
.AddDatatype(new RDFDatatype(new Uri("ex:mydtQG"), RDFModelEnums.RDFDatatypes.XSD_STRING, [
new RDFPatternFacet("^ex$") ])));
DataTable table = store1.ToDataTable();
RDFMemoryStore store2 = await RDFMemoryStore.FromDataTableAsync(table, true);

Assert.IsNotNull(store2);
Assert.IsTrue(store2.QuadruplesCount == 9);
Assert.IsTrue(store2.Equals(store1));
//Test that automatic datatype discovery happened successfully
Assert.IsTrue(RDFDatatypeRegister.GetDatatype("ex:mydtQG").TargetDatatype == RDFModelEnums.RDFDatatypes.XSD_STRING);
Assert.IsTrue(RDFDatatypeRegister.GetDatatype("ex:mydtQG").Facets.Single() is RDFPatternFacet fct && fct.Pattern == "^ex$");
}

[TestMethod]
public async Task ShouldImportEmptyFromDataTableAsync()
{
Expand Down

0 comments on commit ffe6d2c

Please sign in to comment.