Boolean sorting & filtering tests

This commit is contained in:
Biarity 2018-04-08 13:46:16 +10:00
parent 9104ea7693
commit 47fd6307a0
4 changed files with 38 additions and 6 deletions

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata> <metadata>
<id>Sieve</id> <id>Sieve</id>
<version>1.3.92</version> <version>1.3.93</version>
<title>Sieve</title> <title>Sieve</title>
<authors>Biarity</authors> <authors>Biarity</authors>
<owners>Biarity</owners> <owners>Biarity</owners>
@ -13,7 +13,7 @@
<description> <description>
Sieve is a simple, clean, and extensible framework for .NET Core that adds sorting, filtering, and pagination functionality out of the box. Most common use case would be for serving ASP.NET Core GET queries. Documentation available on GitHub: https://github.com/Biarity/Sieve/ Sieve is a simple, clean, and extensible framework for .NET Core that adds sorting, filtering, and pagination functionality out of the box. Most common use case would be for serving ASP.NET Core GET queries. Documentation available on GitHub: https://github.com/Biarity/Sieve/
</description> </description>
<releaseNotes>Base exception type, max pages feature</releaseNotes> <releaseNotes>Fix parse order</releaseNotes>
<copyright>Copyright 2018</copyright> <copyright>Copyright 2018</copyright>
<tags>aspnetcore filter sort page paginate sieve search</tags> <tags>aspnetcore filter sort page paginate sieve search</tags>
<dependencies> <dependencies>

View File

@ -22,6 +22,9 @@ namespace SieveUnitTests.Entities
[Sieve(CanFilter = true, CanSort = true)] [Sieve(CanFilter = true, CanSort = true)]
public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.UtcNow; public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.UtcNow;
[Sieve(CanFilter = true, CanSort = true)]
public bool IsDraft { get; set; }
public string ThisHasNoAttribute { get; set; } public string ThisHasNoAttribute { get; set; }
public string ThisHasNoAttributeButIsAccessible { get; set; } public string ThisHasNoAttributeButIsAccessible { get; set; }

View File

@ -27,12 +27,14 @@ namespace SieveUnitTests
new Post() { new Post() {
Id = 0, Id = 0,
Title = "A", Title = "A",
LikeCount = 100 LikeCount = 100,
IsDraft = true
}, },
new Post() { new Post() {
Id = 1, Id = 1,
Title = "B", Title = "B",
LikeCount = 50 LikeCount = 50,
IsDraft = false
}, },
new Post() { new Post() {
Id = 2, Id = 2,
@ -69,6 +71,33 @@ namespace SieveUnitTests
Assert.IsTrue(result.Count() == 0); 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] [TestMethod]
public void EqualsDoesntFailWithNonStringTypes() public void EqualsDoesntFailWithNonStringTypes()
{ {

View File

@ -1,6 +1,6 @@
### 1. Pack: ### 1. Pack:
``` ```
dotnet pack Sieve.csproj -c Release -o . /p:PackageVersion=1.3.92 dotnet pack Sieve.csproj -c Release -o . /p:PackageVersion=1.3.93
``` ```
Don't forget to change version since nuget packages are immutable (add one to the nuget current). Don't forget to change version since nuget packages are immutable (add one to the nuget current).
@ -13,7 +13,7 @@ Also don't forget updaing `releaseNotes` in nuspec.
### 3. Publish: ### 3. Publish:
``` ```
nuget push Sieve.1.3.92.nupkg API_KEY -Source https://api.nuget.org/v3/index.json nuget push Sieve.1.3.93.nupkg API_KEY -Source https://api.nuget.org/v3/index.json
``` ```
Replace API_KEY with one you get from nuget's website. Replace API_KEY with one you get from nuget's website.
Also don't forget to replace corresponding version. Also don't forget to replace corresponding version.