diff --git a/RDFSharp.Test/Query/Mirella/RDFQueryPrinterTest.cs b/RDFSharp.Test/Query/Mirella/RDFQueryPrinterTest.cs index 137a093f..02554d6f 100644 --- a/RDFSharp.Test/Query/Mirella/RDFQueryPrinterTest.cs +++ b/RDFSharp.Test/Query/Mirella/RDFQueryPrinterTest.cs @@ -503,6 +503,34 @@ public void ShouldPrintSelectQueryStarWithMultipleMinusPatternFollowedByBind() Assert.IsTrue(queryString.Count(chr => chr == '{') == queryString.Count(chr => chr == '}')); } + [TestMethod] + public void ShouldPrintSelectQueryStarWithMultipleMinusPatternFollowedByValues() + { + RDFSelectQuery query = new RDFSelectQuery() + .AddPrefix(RDFNamespaceRegister.GetByPrefix("rdfs")) + .AddPatternGroup(new RDFPatternGroup() + .AddPattern(new RDFPattern(new RDFVariable("?S1"), RDFVocabulary.RDFS.LABEL, new RDFPlainLiteral("label", "en")).MinusWithNext()) + .AddPattern(new RDFPattern(new RDFVariable("?S2"), RDFVocabulary.RDFS.LABEL, new RDFPlainLiteral("label", "en-US")).MinusWithNext()) + .AddValues(new RDFValues().AddColumn(new RDFVariable("?V"), [ new RDFResource("ex:val") ]))); + string queryString = RDFQueryPrinter.PrintSelectQuery(query, 0, false); + string expectedQueryString = +@"PREFIX rdfs: + +SELECT * +WHERE { + { + { ?S1 rdfs:label ""label""@EN } + MINUS + { ?S2 rdfs:label ""label""@EN-US } + MINUS + { VALUES ?V { } } + } +} +"; + Assert.IsTrue(string.Equals(queryString, expectedQueryString)); + Assert.IsTrue(queryString.Count(chr => chr == '{') == queryString.Count(chr => chr == '}')); + } + [TestMethod] public void ShouldPrintSelectQueryStarWithMultipleMinusPatternsHavingMiddleBind() { @@ -529,6 +557,33 @@ public void ShouldPrintSelectQueryStarWithMultipleMinusPatternsHavingMiddleBind( Assert.IsTrue(queryString.Count(chr => chr == '{') == queryString.Count(chr => chr == '}')); } + [TestMethod] + public void ShouldPrintSelectQueryStarWithMultipleMinusPatternsHavingMiddleValues() + { + RDFSelectQuery query = new RDFSelectQuery() + .AddPrefix(RDFNamespaceRegister.GetByPrefix("rdfs")) + .AddPatternGroup(new RDFPatternGroup() + .AddPattern(new RDFPattern(new RDFVariable("?S1"), RDFVocabulary.RDFS.LABEL, new RDFPlainLiteral("label", "en")).MinusWithNext()) + .AddValues(new RDFValues().AddColumn(new RDFVariable("?V"), [ new RDFResource("ex:val") ])) + .AddPattern(new RDFPattern(new RDFVariable("?S2"), RDFVocabulary.RDFS.LABEL, new RDFPlainLiteral("label", "en-US")).MinusWithNext())); + string queryString = RDFQueryPrinter.PrintSelectQuery(query, 0, false); + string expectedQueryString = +@"PREFIX rdfs: + +SELECT * +WHERE { + { + { ?S1 rdfs:label ""label""@EN } + MINUS + { VALUES ?V { } } + ?S2 rdfs:label ""label""@EN-US . + } +} +"; + Assert.IsTrue(string.Equals(queryString, expectedQueryString)); + Assert.IsTrue(queryString.Count(chr => chr == '{') == queryString.Count(chr => chr == '}')); + } + [TestMethod] public void ShouldPrintSelectQueryStarWithSingleMinusPatternGroup() {