Skip to content

Commit

Permalink
add unit test for Where with empty string (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH authored Aug 14, 2022
1 parent bc1923e commit 6a39172
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/System.Linq.Dynamic.Core.Tests/QueryableTests.Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ public void Where_Dynamic_StringQuoted()
Assert.Equal(expected, result2b);
}

[Fact]
public void Where_Dynamic_EmptyString()
{
// Arrange
var testList = User.GenerateSampleModels(2, allowNullableProfiles: true);
var qry = testList.AsQueryable();

// Act
var expected1 = qry.Where(u => u.UserName != string.Empty).ToArray();
var expected2 = qry.Where(u => u.UserName != "").ToArray();
var resultDynamic1 = qry.Where("UserName != @0", string.Empty).ToArray();
var resultDynamic2 = qry.Where("UserName != @0", "").ToArray();

// Assert
resultDynamic1.Should().Contain(expected1);
resultDynamic2.Should().Contain(expected2);
}

[Fact]
public void Where_Dynamic_SelectNewObjects()
{
Expand Down

0 comments on commit 6a39172

Please sign in to comment.