-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CaseInsensitiveFiltering settings and general improvements (#194)
* New feature - #193 * PR refactors * fix: issue 193 and case sensitivity support improvements * test: add string operator test cases * fix: other string operators case insensitive search --------- Co-authored-by: AliReZa Sabouri <[email protected]>
- Loading branch information
1 parent
33718be
commit 0f4b323
Showing
10 changed files
with
370 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
test/EntityFrameworkPostgreSqlIntegrationTests/Issue193Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Gridify; | ||
using Xunit; | ||
|
||
namespace EntityFrameworkPostgreSqlIntegrationTests; | ||
|
||
public class Issue193Tests | ||
{ | ||
|
||
[Fact] | ||
public void ApplyFiltering_WithCaseInsensitiveOperator_ShouldReturnExpectedResult() | ||
{ | ||
// arrange | ||
var dataSource = Test.GetTestDataSource(); | ||
|
||
var expected = dataSource.Where(q => q.FavouriteColorList.Contains("red", StringComparer.InvariantCultureIgnoreCase) | | ||
q.FavouriteColorList.Contains("blue", StringComparer.InvariantCultureIgnoreCase)) | ||
.ToList(); | ||
|
||
// act | ||
var actual = dataSource.ApplyFiltering("FavouriteColorList=red/i|FavouriteColorList=blue/i").ToList(); | ||
|
||
// assert | ||
Assert.NotEmpty(expected); | ||
Assert.NotEmpty(actual); | ||
Assert.Equal(expected.Count, actual.Count); | ||
} | ||
|
||
[Fact] | ||
public void ApplyFiltering_WithDefaultCaseInsensitiveFiltering_ShouldReturnExpectedResult() | ||
{ | ||
// arrange | ||
var dataSource = Test.GetTestDataSource(); | ||
|
||
var expected = dataSource.Where(q => q.FavouriteColorList.Contains("red", StringComparer.InvariantCultureIgnoreCase) | | ||
q.FavouriteColorList.Contains("blue", StringComparer.InvariantCultureIgnoreCase)) | ||
.ToList(); | ||
|
||
var mapper = new GridifyMapper<Test>(q => q.CaseInsensitiveFiltering = true).GenerateMappings(); | ||
|
||
// act | ||
var actual = dataSource.ApplyFiltering("FavouriteColorList=red|FavouriteColorList=blue", mapper).ToList(); | ||
|
||
// assert | ||
Assert.NotEmpty(expected); | ||
Assert.NotEmpty(actual); | ||
Assert.Equal(expected.Count, actual.Count); | ||
} | ||
|
||
class Test | ||
{ | ||
public string[] FavouriteColorList { get; set; } | ||
Check warning on line 51 in test/EntityFrameworkPostgreSqlIntegrationTests/Issue193Tests.cs GitHub Actions / Analyze (csharp)
|
||
|
||
public static IQueryable<Test> GetTestDataSource() | ||
{ | ||
return new List<Test>() | ||
{ | ||
new() { FavouriteColorList = ["Green", "Blue"] }, | ||
new() { FavouriteColorList = ["White", "Yellow"] }, | ||
new() { FavouriteColorList = ["Red", "Orange"] }, | ||
new() { FavouriteColorList = ["Purple", "Pink"] }, | ||
new() { FavouriteColorList = ["Black", "Gray"] } | ||
}.AsQueryable(); | ||
} | ||
} | ||
} |
Oops, something went wrong.