Skip to content

Commit

Permalink
Added 2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco De Salvo committed Dec 5, 2024
1 parent 6a2f200 commit 8498eb6
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions RDFSharp.Test/Query/Mirella/RDFQueryPrinterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE {
{
{ ?S1 rdfs:label ""label""@EN }
MINUS
{ ?S2 rdfs:label ""label""@EN-US }
MINUS
{ VALUES ?V { <ex:val> } }
}
}
";
Assert.IsTrue(string.Equals(queryString, expectedQueryString));
Assert.IsTrue(queryString.Count(chr => chr == '{') == queryString.Count(chr => chr == '}'));
}

[TestMethod]
public void ShouldPrintSelectQueryStarWithMultipleMinusPatternsHavingMiddleBind()
{
Expand All @@ -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: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE {
{
{ ?S1 rdfs:label ""label""@EN }
MINUS
{ VALUES ?V { <ex:val> } }
?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()
{
Expand Down

0 comments on commit 8498eb6

Please sign in to comment.