mirror of
https://github.com/Biarity/Sieve.git
synced 2025-08-17 22:55:32 +02:00
stop excluding null values when filtering using notEqual (#114)
* stop excluding null values when filtering using notEqual * add IgnoreNullsOnNotEqual config field, to enable/disable the new feature Co-authored-by: AnasZakarneh <a.zakarneh@foothillsolutions.com>
This commit is contained in:
@@ -15,16 +15,24 @@ namespace SieveUnitTests
|
||||
{
|
||||
private readonly ITestOutputHelper _testOutputHelper;
|
||||
private readonly SieveProcessor _processor;
|
||||
private readonly SieveProcessor _nullableProcessor;
|
||||
private readonly IQueryable<Post> _posts;
|
||||
private readonly IQueryable<Comment> _comments;
|
||||
|
||||
public General(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
var nullableAccessor = new SieveOptionsAccessor();
|
||||
nullableAccessor.Value.IgnoreNullsOnNotEqual = false;
|
||||
|
||||
_testOutputHelper = testOutputHelper;
|
||||
_processor = new ApplicationSieveProcessor(new SieveOptionsAccessor(),
|
||||
new SieveCustomSortMethods(),
|
||||
new SieveCustomFilterMethods());
|
||||
|
||||
_nullableProcessor = new ApplicationSieveProcessor(nullableAccessor,
|
||||
new SieveCustomSortMethods(),
|
||||
new SieveCustomFilterMethods());
|
||||
|
||||
_posts = new List<Post>
|
||||
{
|
||||
new Post
|
||||
@@ -180,10 +188,27 @@ namespace SieveUnitTests
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, _posts);
|
||||
var nullableResult = _nullableProcessor.Apply(model, _posts);
|
||||
|
||||
Assert.True(result.Count() == 2);
|
||||
Assert.True(nullableResult.Count() == 2);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void CanFilterNullableIntsWithNotEqual()
|
||||
{
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Filters = "CategoryId!=1"
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, _posts);
|
||||
var nullableResult = _nullableProcessor.Apply(model, _posts);
|
||||
|
||||
Assert.True(result.Count() == 1);
|
||||
Assert.True(nullableResult.Count() == 2);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"Text@=*\,")]
|
||||
[InlineData(@"Text@=*\, ")]
|
||||
|
@@ -16,16 +16,24 @@ namespace SieveUnitTests
|
||||
{
|
||||
private readonly ITestOutputHelper _testOutputHelper;
|
||||
private readonly SieveProcessor _processor;
|
||||
private readonly SieveProcessor _nullableProcessor;
|
||||
private readonly IQueryable<IPost> _posts;
|
||||
private readonly IQueryable<Comment> _comments;
|
||||
|
||||
public GeneralWithInterfaces(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
var nullableAccessor = new SieveOptionsAccessor();
|
||||
nullableAccessor.Value.IgnoreNullsOnNotEqual = false;
|
||||
|
||||
_testOutputHelper = testOutputHelper;
|
||||
_processor = new ApplicationSieveProcessor(new SieveOptionsAccessor(),
|
||||
new SieveCustomSortMethods(),
|
||||
new SieveCustomFilterMethods());
|
||||
|
||||
_nullableProcessor = new ApplicationSieveProcessor(nullableAccessor,
|
||||
new SieveCustomSortMethods(),
|
||||
new SieveCustomFilterMethods());
|
||||
|
||||
_posts = new List<IPost>
|
||||
{
|
||||
new Post
|
||||
@@ -181,8 +189,25 @@ namespace SieveUnitTests
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, _posts);
|
||||
var nullableResult = _nullableProcessor.Apply(model, _posts);
|
||||
|
||||
Assert.True(result.Count() == 2);
|
||||
Assert.True(nullableResult.Count() == 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanFilterNullableIntsWithNotEqual()
|
||||
{
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Filters = "CategoryId!=1"
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, _posts);
|
||||
var nullableResult = _nullableProcessor.Apply(model, _posts);
|
||||
|
||||
Assert.True(result.Count() == 1);
|
||||
Assert.True(nullableResult.Count() == 2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Reference in New Issue
Block a user