mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-28 13:13:02 +02:00
* #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>
This commit is contained in:
@@ -613,5 +613,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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user