#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>
This commit is contained in:
Clayton Andersen
2021-05-15 04:50:12 -07:00
committed by GitHub
parent 7ced211758
commit 285468522c
3 changed files with 63 additions and 3 deletions

View File

@@ -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());
}
}
}