Skip to content

Commit

Permalink
Added further test to demonstrate centrality of datatype register
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco De Salvo committed May 27, 2024
1 parent 7326fa6 commit 276eb60
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions RDFSharp.Test/Model/Serializers/RDFXMLTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ public void ShouldDeserializeGraphWithCustomDatatypeSPLTTriple()
Assert.IsTrue(graph.ContainsTriple(new RDFTriple(new RDFResource("http://subj/"), new RDFResource("http://pred/pred"), new RDFTypedLiteral("25", RDFModelEnums.RDFDatatypes.RDFS_LITERAL))));
}

[TestMethod]
public void ShouldDeserializeGraphWithRegisteredCustomDatatypeSPLTTriple()
{
RDFDatatypeRegister.AddDatatype(new RDFDatatype(new Uri("http://test.dt/"), RDFModelEnums.RDFDatatypes.XSD_INTEGER, null));
MemoryStream stream = new MemoryStream();
using (StreamWriter writer = new StreamWriter(stream))
writer.WriteLine($"{XmlHeader}{Environment.NewLine}<rdf:RDF {XmlNsRDF} xmlns:autoNS1=\"http://pred/\" {XmlBaseDefault}>{Environment.NewLine}{" ",2}<rdf:Description rdf:about=\"http://subj/\">{Environment.NewLine}{" ",4}<autoNS1:pred rdf:datatype=\"http://test.dt/\">25</autoNS1:pred>{Environment.NewLine}{" ",2}</rdf:Description>{Environment.NewLine}</rdf:RDF>");
RDFGraph graph = RDFXml.Deserialize(new MemoryStream(stream.ToArray()), null);

Assert.IsNotNull(graph);
Assert.IsTrue(graph.Context.Equals(RDFNamespaceRegister.DefaultNamespace.NamespaceUri));
Assert.IsTrue(graph.ContainsTriple(new RDFTriple(new RDFResource("http://subj/"), new RDFResource("http://pred/pred"), new RDFTypedLiteral("25", new RDFDatatype(new Uri("http://test.dt/"), RDFModelEnums.RDFDatatypes.XSD_INTEGER, null)))));
}

[TestMethod]
public void ShouldDeserializeGraphWithSPLTripleHavingDTDEntityAsLiteral()
{
Expand Down

0 comments on commit 276eb60

Please sign in to comment.