mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-26 12:13:28 +02:00
Boolean sorting & filtering tests
This commit is contained in:
@@ -22,6 +22,9 @@ namespace SieveUnitTests.Entities
|
||||
[Sieve(CanFilter = true, CanSort = true)]
|
||||
public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
[Sieve(CanFilter = true, CanSort = true)]
|
||||
public bool IsDraft { get; set; }
|
||||
|
||||
public string ThisHasNoAttribute { get; set; }
|
||||
|
||||
public string ThisHasNoAttributeButIsAccessible { get; set; }
|
||||
|
@@ -27,12 +27,14 @@ namespace SieveUnitTests
|
||||
new Post() {
|
||||
Id = 0,
|
||||
Title = "A",
|
||||
LikeCount = 100
|
||||
LikeCount = 100,
|
||||
IsDraft = true
|
||||
},
|
||||
new Post() {
|
||||
Id = 1,
|
||||
Title = "B",
|
||||
LikeCount = 50
|
||||
LikeCount = 50,
|
||||
IsDraft = false
|
||||
},
|
||||
new Post() {
|
||||
Id = 2,
|
||||
@@ -69,6 +71,33 @@ namespace SieveUnitTests
|
||||
Assert.IsTrue(result.Count() == 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanFilterBools()
|
||||
{
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Filters = "IsDraft==false"
|
||||
};
|
||||
|
||||
var result = _processor.ApplyAll(model, _posts);
|
||||
|
||||
Assert.IsTrue(result.Count() == 2);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void CanSortBools()
|
||||
{
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Sorts = "-IsDraft"
|
||||
};
|
||||
|
||||
var result = _processor.ApplyAll(model, _posts);
|
||||
|
||||
Assert.AreEqual(result.First().Id, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EqualsDoesntFailWithNonStringTypes()
|
||||
{
|
||||
|
Reference in New Issue
Block a user