From b685b72b026c316ff23689679343567dff77817c Mon Sep 17 00:00:00 2001 From: mdesalvo Date: Fri, 4 Oct 2024 19:29:46 +0200 Subject: [PATCH] Added a test for collection reification --- RDFSharp.Test/Model/RDFCollectionTest.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/RDFSharp.Test/Model/RDFCollectionTest.cs b/RDFSharp.Test/Model/RDFCollectionTest.cs index 1378683d..17784e52 100644 --- a/RDFSharp.Test/Model/RDFCollectionTest.cs +++ b/RDFSharp.Test/Model/RDFCollectionTest.cs @@ -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)); } @@ -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 } } \ No newline at end of file