mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-26 12:13:28 +02:00
Set up Nullable Test
This commit is contained in:
@@ -19,6 +19,9 @@ namespace SieveUnitTests.Entities
|
||||
[Sieve(CanFilter = true, CanSort = true)]
|
||||
public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.UtcNow;
|
||||
|
||||
[Sieve(CanFilter = true, CanSort = true)]
|
||||
public int? CategoryId { get; set; } = new Random().Next(0, 4);
|
||||
|
||||
[Sieve(CanFilter = true, CanSort = true)]
|
||||
public bool IsDraft { get; set; }
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -28,24 +28,28 @@ namespace SieveUnitTests
|
||||
Id = 0,
|
||||
Title = "A",
|
||||
LikeCount = 100,
|
||||
IsDraft = true
|
||||
IsDraft = true,
|
||||
CategoryId = null,
|
||||
},
|
||||
new Post() {
|
||||
Id = 1,
|
||||
Title = "B",
|
||||
LikeCount = 50,
|
||||
IsDraft = false
|
||||
IsDraft = false,
|
||||
CategoryId = 1,
|
||||
},
|
||||
new Post() {
|
||||
Id = 2,
|
||||
Title = "C",
|
||||
LikeCount = 0
|
||||
LikeCount = 0,
|
||||
CategoryId = 1,
|
||||
},
|
||||
new Post() {
|
||||
Id = 3,
|
||||
Title = "D",
|
||||
LikeCount = 3,
|
||||
IsDraft = true
|
||||
IsDraft = true,
|
||||
CategoryId = 2,
|
||||
},
|
||||
}.AsQueryable();
|
||||
}
|
||||
@@ -103,6 +107,19 @@ namespace SieveUnitTests
|
||||
Assert.AreEqual(result.First().Id, 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanFilterNullableInts()
|
||||
{
|
||||
var model = new SieveModel()
|
||||
{
|
||||
Filters = "CategoryId==1"
|
||||
};
|
||||
|
||||
var result = _processor.Apply(model, _posts);
|
||||
|
||||
Assert.IsTrue(result.Count() == 2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EqualsDoesntFailWithNonStringTypes()
|
||||
{
|
||||
@@ -174,4 +191,4 @@ namespace SieveUnitTests
|
||||
Assert.AreEqual(3, entry.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user