From 39e06fb590f6fd143611776911e6b1482fe728c6 Mon Sep 17 00:00:00 2001 From: mdesalvo Date: Wed, 1 Nov 2023 18:14:38 +0100 Subject: [PATCH] Update tests --- RDFSharp.Test/Model/RDFGraphTest.cs | 25 +++++++++++++++++++++++++ RDFSharp.Test/Model/RDFTripleTest.cs | 4 ++++ RDFSharp.Test/RDFSharp.Test.csproj | 2 +- RDFSharp/RDFSharp.csproj | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/RDFSharp.Test/Model/RDFGraphTest.cs b/RDFSharp.Test/Model/RDFGraphTest.cs index dc88bc05..98e4e2cf 100644 --- a/RDFSharp.Test/Model/RDFGraphTest.cs +++ b/RDFSharp.Test/Model/RDFGraphTest.cs @@ -255,6 +255,31 @@ public void ShouldAddTripleAsImport() Assert.IsTrue(graph.Count(t => t.TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsImport) == 1); } + [TestMethod] + public void ShouldAddTriplesMixingMetadata() + { + RDFGraph graph = new RDFGraph(); + RDFTriple triple1 = new RDFTriple(new RDFResource("http://subj/"), new RDFResource("http://pred/"), new RDFPlainLiteral("lit","en-US")); + RDFTriple triple2 = new RDFTriple(new RDFResource("http://subj/"), new RDFResource("http://pred/"), new RDFResource("http://obj/")) + .SetMetadata(RDFModelEnums.RDFTripleMetadata.IsInference); + RDFTriple triple3 = new RDFTriple(new RDFResource("http://subj/"), new RDFResource("http://pred/"), new RDFPlainLiteral("lit")) + .SetMetadata(RDFModelEnums.RDFTripleMetadata.IsImport); + graph.AddTriple(triple1); + graph.AddTriple(triple2); + graph.AddTriple(triple3); + + Assert.IsTrue(graph.TriplesCount == 3); + Assert.IsTrue(graph.IndexedTriples.ContainsKey(triple1.TripleID)); + Assert.IsTrue(graph.IndexedTriples[triple1.TripleID].TripleMetadata is null); + Assert.IsTrue(graph.IndexedTriples.ContainsKey(triple2.TripleID)); + Assert.IsTrue(graph.IndexedTriples[triple2.TripleID].TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsInference); + Assert.IsTrue(graph.IndexedTriples.ContainsKey(triple3.TripleID)); + Assert.IsTrue(graph.IndexedTriples[triple3.TripleID].TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsImport); + Assert.IsTrue(graph.Count(t => t.TripleMetadata is null) == 1); + Assert.IsTrue(graph.Count(t => t.TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsInference) == 1); + Assert.IsTrue(graph.Count(t => t.TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsImport) == 1); + } + [TestMethod] public void ShouldNotAddDuplicateTriples() { diff --git a/RDFSharp.Test/Model/RDFTripleTest.cs b/RDFSharp.Test/Model/RDFTripleTest.cs index 046651fa..456e19af 100644 --- a/RDFSharp.Test/Model/RDFTripleTest.cs +++ b/RDFSharp.Test/Model/RDFTripleTest.cs @@ -52,6 +52,10 @@ public void ShouldCreateSPOTriple(string s, string p, string o) Assert.IsNull(triple.TripleMetadata); triple.SetMetadata(RDFModelEnums.RDFTripleMetadata.IsInference); Assert.IsTrue(triple.TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsInference); + triple.SetMetadata(RDFModelEnums.RDFTripleMetadata.IsImport); + Assert.IsTrue(triple.TripleMetadata == RDFModelEnums.RDFTripleMetadata.IsImport); + triple.SetMetadata(null); + Assert.IsTrue(triple.TripleMetadata is null); } [DataTestMethod] diff --git a/RDFSharp.Test/RDFSharp.Test.csproj b/RDFSharp.Test/RDFSharp.Test.csproj index 55aa9270..ade287a5 100644 --- a/RDFSharp.Test/RDFSharp.Test.csproj +++ b/RDFSharp.Test/RDFSharp.Test.csproj @@ -3,7 +3,7 @@ RDFSharp.Test RDFSharp.Test $(Version) - 3.8.1 + 3.9.0 Marco De Salvo Marco De Salvo net6.0 diff --git a/RDFSharp/RDFSharp.csproj b/RDFSharp/RDFSharp.csproj index 19da9d16..aa16b341 100644 --- a/RDFSharp/RDFSharp.csproj +++ b/RDFSharp/RDFSharp.csproj @@ -3,7 +3,7 @@ RDFSharp RDFSharp $(Version) - 3.8.1 + 3.9.0 Marco De Salvo Marco De Salvo Lightweight and friendly .NET library for realizing Semantic Web applications