Skip to content

Commit

Permalink
Added a test for collection reification
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesalvo committed Oct 4, 2024
1 parent 084e73f commit b685b72
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion RDFSharp.Test/Model/RDFCollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void ShouldAddItemsToCollection(RDFModelEnums.RDFItemTypes itemType)
coll.AddItem(new RDFResource("http://item/"));
}

Assert.IsTrue(coll.ItemsCount == 2); //Duplicates are allowed (e.g.: OWL property chains)
Assert.IsTrue(coll.ItemsCount == 2);
Assert.IsFalse(coll.ReificationSubject.Equals(RDFVocabulary.RDF.NIL));
}

Expand Down Expand Up @@ -279,6 +279,25 @@ public void ShouldReifyCollectionWithTwoItems(RDFModelEnums.RDFItemTypes itemTyp
Assert.IsTrue(graph.SelectTriplesByPredicate(RDFVocabulary.RDF.REST)
.TriplesCount == 2);
}

[TestMethod]
public void ShouldReifyCollectionWithInternallyMixedItems()
{
RDFCollection coll = new RDFCollection(RDFModelEnums.RDFItemTypes.Resource);
coll.AddItemInternal(new RDFPlainLiteral("lit1"));
coll.AddItemInternal(new RDFResource("http://item1/"));
RDFGraph graph = coll.ReifyCollection();

Assert.IsNotNull(graph);
Assert.IsTrue(graph.TriplesCount == 6);
Assert.IsTrue(graph.SelectTriplesByPredicate(RDFVocabulary.RDF.TYPE)
.SelectTriplesByObject(RDFVocabulary.RDF.LIST)
.TriplesCount == 2);
Assert.IsTrue(graph.SelectTriplesByPredicate(RDFVocabulary.RDF.FIRST)
.TriplesCount == 2);
Assert.IsTrue(graph.SelectTriplesByPredicate(RDFVocabulary.RDF.REST)
.TriplesCount == 2);
}
#endregion
}
}

0 comments on commit b685b72

Please sign in to comment.