mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-26 12:13:28 +02:00
Release Sieve 2.5.0 (#151)
* Setup release 2.5.0 with automated build and pre-releases * #80 added support for escaping pipe control characters (#113) * #80 added support for escaping comma and pipe control characters * Update SieveModel.cs Fix build. Accidentally broken by resolving conflicts. * Migrate UnitTests to xUnit Co-authored-by: Clayton Andersen <candersen@restaurant365.com> Co-authored-by: ITDancer13 <kevin@ksommer.eu> Co-authored-by: ITDancer139 <kevinitdancersommer@gmail.com> * SieveProcessor.Options made protected property (#134) Mapper assignment in constructor is moved to a null-coalescing member pair (a field and a property) "IncludeScopes" switch is removed from appSettings.{env}.json files * Revert to _mapper assignment in constructor. (#140) * reverting fix (#142) * Revert to _mapper assignment in constructor. * reverting fix * pass filter values as parameters (#112) make GetClosureOverConstant really work * Make ApplyFiltering, ApplySorting and ApplyPagination protected virtual #139 (#144) * 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> Co-authored-by: Clayton Andersen <tunaman65@gmail.com> Co-authored-by: Clayton Andersen <candersen@restaurant365.com> Co-authored-by: ITDancer139 <kevinitdancersommer@gmail.com> Co-authored-by: Hasan Manzak <hasan.manzak@gmail.com> Co-authored-by: alicak <alicak@users.noreply.github.com> Co-authored-by: AnasZakarneh <Zakarnehanas1@gmail.com> 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@=*\, ")]
|
||||
@@ -613,5 +638,61 @@ namespace SieveUnitTests
|
||||
Assert.Equal(1,posts[2].Id);
|
||||
Assert.Equal(0,posts[3].Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanFilter_WithEscapeCharacter()
|
||||
{
|
||||
var comments = new List<Comment>
|
||||
{
|
||||
new Comment
|
||||
{
|
||||
Id = 0,
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Text = "Here is, a comment"
|
||||
},
|
||||
new Comment
|
||||
{
|
||||
Id = 1,
|
||||
DateCreated = DateTimeOffset.UtcNow.AddDays(-1),
|
||||
Text = "Here is, another comment"
|
||||
},
|
||||
}.AsQueryable();
|
||||
|
||||
var model = new SieveModel
|
||||
{
|
||||
Filters = "Text==Here is\\, another comment"
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, comments);
|
||||
Assert.Equal(1, result.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OrEscapedPipeValueFilteringWorks()
|
||||
{
|
||||
var comments = new List<Comment>
|
||||
{
|
||||
new Comment
|
||||
{
|
||||
Id = 0,
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Text = "Here is | a comment"
|
||||
},
|
||||
new Comment
|
||||
{
|
||||
Id = 1,
|
||||
DateCreated = DateTimeOffset.UtcNow.AddDays(-1),
|
||||
Text = "Here is | another comment"
|
||||
},
|
||||
}.AsQueryable();
|
||||
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Filters = "Text==Here is \\| a comment|Here is \\| another comment",
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, comments);
|
||||
Assert.Equal(2, result.Count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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