Skip to content

Commit

Permalink
Add more test cases and refactor Assert
Browse files Browse the repository at this point in the history
  • Loading branch information
WanjohiSammy committed Nov 18, 2024
1 parent f4caa0c commit b75161f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,34 @@ public async Task DollarFilter_UsingContains_ExecutesSuccessfully(string query,
}

[Theory]
[InlineData("People?$filter=Name in ('')", 0)]
[InlineData("People?$filter=Name in ['']", 0)]
[InlineData("People?$filter=Name in ( '' )", 0)]
[InlineData("People?$filter=Name in [ '' ]", 0)]
[InlineData("People?$filter=Name in (\"\")", 0)]
[InlineData("People?$filter=Name in [\"\"]", 0)]
[InlineData("People?$filter=Name in ( \"\" )", 0)]
[InlineData("People?$filter=Name in [ \"\" ]", 0)]
[InlineData("People?$filter=Name in ( ' ' )", 0)]
[InlineData("People?$filter=Name in [ ' ' ]", 0)]
[InlineData("People?$filter=Name in ( \" \" )", 0)]
[InlineData("People?$filter=Name in [ \" \"]", 0)]
[InlineData("People?$filter=Name in ( '', ' ' )", 0)]
[InlineData("People?$filter=Name in [ '', ' ' ]", 0)]
[InlineData("People?$filter=Name in ( \"\", \" \" )", 0)]
[InlineData("People?$filter=Name in [ \"\", \" \" ]", 0)]
[InlineData("People?$filter=Name in ( '', \" \" )", 0)]
[InlineData("People?$filter=Name in [ '', \" \" ]", 0)]
[InlineData("People?$filter=Name in ( \"\", ' ' )", 0)]
[InlineData("People?$filter=Name in [ \"\", ' ' ]", 0)]
[InlineData("People?$filter=Name in [ 'null', 'null' ]", 0)]
public async Task DollarFilter_WithCollectionWithEmptyString_ExecutesSuccessfully(string query, int expectedCount)
[InlineData("People?$filter=Name in ('')")]
[InlineData("People?$filter=Name in ['']")]
[InlineData("People?$filter=Name in ( '' )")]
[InlineData("People?$filter=Name in [ '' ]")]
[InlineData("People?$filter=Name in (\"\")")]
[InlineData("People?$filter=Name in [\"\"]")]
[InlineData("People?$filter=Name in ( \"\" )")]
[InlineData("People?$filter=Name in [ \"\" ]")]
[InlineData("People?$filter=Name in ( ' ' )")]
[InlineData("People?$filter=Name in [ ' ' ]")]
[InlineData("People?$filter=Name in ( \" \" )")]
[InlineData("People?$filter=Name in [ \" \"]")]
[InlineData("People?$filter=Name in ( '', ' ' )")]
[InlineData("People?$filter=Name in [ '', ' ' ]")]
[InlineData("People?$filter=Name in ( \"\", \" \" )")]
[InlineData("People?$filter=Name in [ \"\", \" \" ]")]
[InlineData("People?$filter=Name in ( '', \" \" )")]
[InlineData("People?$filter=Name in [ '', \" \" ]")]
[InlineData("People?$filter=Name in ( \"\", ' ' )")]
[InlineData("People?$filter=Name in [ \"\", ' ' ]")]
[InlineData("People?$filter=Name in [ 'null', 'null' ]")]
public async Task DollarFilter_WithCollectionWithEmptyString_ExecutesSuccessfully(string query)
{
// Act
var response = await _context.ExecuteAsync<Common.Clients.EndToEnd.Person>(new Uri(_baseUri.OriginalString + query));

// Assert
Assert.Equal(expectedCount, response.ToArray().Length);
Assert.Empty(response.ToArray());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2413,45 +2413,86 @@ public void FilterWithInOperationWithParensStringCollection_EscapedSingleQuote()

[Theory]
[InlineData("('a''bc')", "('a''bc')", 1)]
[InlineData("['a''bc']", "['a''bc']", 1)]
[InlineData("('''def')", "('''def')", 1)]
[InlineData("['''def']", "['''def']", 1)]
[InlineData("('xyz''')", "('xyz''')", 1)]
[InlineData("['xyz''']", "['xyz''']", 1)]
[InlineData("('''pqr''')", "('''pqr''')", 1)]
[InlineData("['''pqr''']", "['''pqr''']", 1)]
[InlineData("('a''bc','''def')", "('a''bc','''def')", 2)]
[InlineData("['a''bc','''def']", "['a''bc','''def']", 2)]
[InlineData("('a''bc','xyz''')", "('a''bc','xyz''')", 2)]
[InlineData("['a''bc','xyz''']", "['a''bc','xyz''']", 2)]
[InlineData("('a''bc','''pqr''')", "('a''bc','''pqr''')", 2)]
[InlineData("['a''bc','''pqr''']", "['a''bc','''pqr''']", 2)]
[InlineData("('''def','a''bc')", "('''def','a''bc')", 2)]
[InlineData("['''def','a''bc']", "['''def','a''bc']", 2)]
[InlineData("('''def','xyz''')", "('''def','xyz''')", 2)]
[InlineData("['''def','xyz''']", "['''def','xyz''']", 2)]
[InlineData("('''def','''pqr''')", "('''def','''pqr''')", 2)]
[InlineData("['''def','''pqr''']", "['''def','''pqr''']", 2)]
[InlineData("('xyz''','a''bc')", "('xyz''','a''bc')", 2)]
[InlineData("['xyz''','a''bc']", "['xyz''','a''bc']", 2)]
[InlineData("('xyz''','''def')", "('xyz''','''def')", 2)]
[InlineData("['xyz''','''def']", "['xyz''','''def']", 2)]
[InlineData("('xyz''','''pqr''')", "('xyz''','''pqr''')", 2)]
[InlineData("['xyz''','''pqr''']", "['xyz''','''pqr''']", 2)]
[InlineData("('''pqr''','a''bc')", "('''pqr''','a''bc')", 2)]
[InlineData("['''pqr''','a''bc']", "['''pqr''','a''bc']", 2)]
[InlineData("('''pqr''','''def')", "('''pqr''','''def')", 2)]
[InlineData("['''pqr''','''def']", "['''pqr''','''def']", 2)]
[InlineData("('''pqr''','xyz''')", "('''pqr''','xyz''')", 2)]
[InlineData("['''pqr''','xyz''']", "['''pqr''','xyz''']", 2)]
[InlineData("('a''bc','''def','xyz''')", "('a''bc','''def','xyz''')", 3)]
[InlineData("['a''bc','''def','xyz''']", "['a''bc','''def','xyz''']", 3)]
[InlineData("('a''bc','''def','''pqr''')", "('a''bc','''def','''pqr''')", 3)]
[InlineData("['a''bc','''def','''pqr''']", "['a''bc','''def','''pqr''']", 3)]
[InlineData("('a''bc','xyz''','''def')", "('a''bc','xyz''','''def')", 3)]
[InlineData("['a''bc','xyz''','''def']", "['a''bc','xyz''','''def']", 3)]
[InlineData("('a''bc','xyz''','''pqr''')", "('a''bc','xyz''','''pqr''')", 3)]
[InlineData("['a''bc','xyz''','''pqr''']", "['a''bc','xyz''','''pqr''']", 3)]
[InlineData("('a''bc','''pqr''','''def')", "('a''bc','''pqr''','''def')", 3)]
[InlineData("['a''bc','''pqr''','''def']", "['a''bc','''pqr''','''def']", 3)]
[InlineData("('a''bc','''pqr''','xyz''')", "('a''bc','''pqr''','xyz''')", 3)]
[InlineData("['a''bc','''pqr''','xyz''']", "['a''bc','''pqr''','xyz''']", 3)]
[InlineData("('''def','a''bc','xyz''')", "('''def','a''bc','xyz''')", 3)]
[InlineData("['''def','a''bc','xyz''']", "['''def','a''bc','xyz''']", 3)]
[InlineData("('''def','a''bc','''pqr''')", "('''def','a''bc','''pqr''')", 3)]
[InlineData("['''def','a''bc','''pqr''']", "['''def','a''bc','''pqr''']", 3)]
[InlineData("('''def','xyz''','a''bc')", "('''def','xyz''','a''bc')", 3)]
[InlineData("['''def','xyz''','a''bc']", "['''def','xyz''','a''bc']", 3)]
[InlineData("('''def','xyz''','''pqr''')", "('''def','xyz''','''pqr''')", 3)]
[InlineData("['''def','xyz''','''pqr''']", "['''def','xyz''','''pqr''']", 3)]
[InlineData("('''def','''pqr''','a''bc')", "('''def','''pqr''','a''bc')", 3)]
[InlineData("['''def','''pqr''','a''bc']", "['''def','''pqr''','a''bc']", 3)]
[InlineData("('''def','''pqr''','xyz''')", "('''def','''pqr''','xyz''')", 3)]
[InlineData("['''def','''pqr''','xyz''']", "['''def','''pqr''','xyz''']", 3)]
[InlineData("('xyz''','a''bc','''def')", "('xyz''','a''bc','''def')", 3)]
[InlineData("['xyz''','a''bc','''def']", "['xyz''','a''bc','''def']", 3)]
[InlineData("('xyz''','a''bc','''pqr''')", "('xyz''','a''bc','''pqr''')", 3)]
[InlineData("['xyz''','a''bc','''pqr''']", "['xyz''','a''bc','''pqr''']", 3)]
[InlineData("('xyz''','''def','''pqr''')", "('xyz''','''def','''pqr''')", 3)]
[InlineData("['xyz''','''def','''pqr''']", "['xyz''','''def','''pqr''']", 3)]
[InlineData("('xyz''','''def','a''bc')", "('xyz''','''def','a''bc')", 3)]
[InlineData("['xyz''','''def','a''bc']", "['xyz''','''def','a''bc']", 3)]
[InlineData("('xyz''','''pqr''','a''bc')", "('xyz''','''pqr''','a''bc')", 3)]
[InlineData("['xyz''','''pqr''','a''bc']", "['xyz''','''pqr''','a''bc']", 3)]
[InlineData("('xyz''','''pqr''','''def')", "('xyz''','''pqr''','''def')", 3)]
[InlineData("['xyz''','''pqr''','''def']", "['xyz''','''pqr''','''def']", 3)]
[InlineData("('''pqr''','a''bc','''def')", "('''pqr''','a''bc','''def')", 3)]
[InlineData("['''pqr''','a''bc','''def']", "['''pqr''','a''bc','''def']", 3)]
[InlineData("('''pqr''','a''bc','xyz''')", "('''pqr''','a''bc','xyz''')", 3)]
[InlineData("['''pqr''','a''bc','xyz''']", "['''pqr''','a''bc','xyz''']", 3)]
[InlineData("('''pqr''','''def','a''bc')", "('''pqr''','''def','a''bc')", 3)]
[InlineData("['''pqr''','''def','a''bc']", "['''pqr''','''def','a''bc']", 3)]
[InlineData("('''pqr''','''def','xyz''')", "('''pqr''','''def','xyz''')", 3)]
[InlineData("['''pqr''','''def','xyz''']", "['''pqr''','''def','xyz''']", 3)]
[InlineData("('''pqr''','xyz''','a''bc')", "('''pqr''','xyz''','a''bc')", 3)]
[InlineData("['''pqr''','xyz''','a''bc']", "['''pqr''','xyz''','a''bc']", 3)]
[InlineData("('''pqr''','xyz''','''def')", "('''pqr''','xyz''','''def')", 3)]
[InlineData("['''pqr''','xyz''','''def']", "['''pqr''','xyz''','''def']", 3)]

public void FilterWithInExpressionContainingEscapedSingleQuotes(string inExpr, string parsedExpr, int count)
{
FilterClause filter = ParseFilter($"SSN in {inExpr}", HardCodedTestModel.TestModel, HardCodedTestModel.GetPersonType());
Expand Down Expand Up @@ -2749,7 +2790,7 @@ public void FilterWithInOperationWithWhitespace(string filterClause, string expe
CollectionConstantNode collectionNode = Assert.IsType<CollectionConstantNode>(inNode.Right);

// A single whitespace or multiple whitespaces are valid literals
Assert.Equal(1, collectionNode.Collection.Count);
Assert.Single(collectionNode.Collection);

ConstantNode constantNode = collectionNode.Collection.First();
Assert.Equal(expectedLiteralText, constantNode.LiteralText);
Expand All @@ -2769,7 +2810,7 @@ public void FilterWithInOperationWithWhitespaceInSquareBrackets(string filterCla
CollectionConstantNode collectionNode = Assert.IsType<CollectionConstantNode>(inNode.Right);

// A single whitespace or multiple whitespaces are valid literals
Assert.Equal(1, collectionNode.Collection.Count);
Assert.Single(collectionNode.Collection);

ConstantNode constantNode = collectionNode.Collection.First();
Assert.Equal(expectedLiteralText, constantNode.LiteralText);
Expand Down

0 comments on commit b75161f

Please sign in to comment.