mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-27 04:33:23 +02:00
Added case-insensitive operators and started unit tests project
This commit is contained in:
20
SieveUnitTests/Services/SieveCustomFilterMethods.cs
Normal file
20
SieveUnitTests/Services/SieveCustomFilterMethods.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Sieve.Services;
|
||||
using SieveUnitTests.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SieveUnitTests.Services
|
||||
{
|
||||
public class SieveCustomFilterMethods : ISieveCustomFilterMethods
|
||||
{
|
||||
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string value)
|
||||
{
|
||||
var result = source.Where(p => p.LikeCount < 100 &&
|
||||
p.CommentCount < 5);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
23
SieveUnitTests/Services/SieveCustomSortMethods.cs
Normal file
23
SieveUnitTests/Services/SieveCustomSortMethods.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Sieve.Services;
|
||||
using SieveUnitTests.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SieveUnitTests.Services
|
||||
{
|
||||
public class SieveCustomSortMethods : ISieveCustomSortMethods
|
||||
{
|
||||
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy, bool desc)
|
||||
{
|
||||
var result = useThenBy ?
|
||||
((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount) :
|
||||
source.OrderBy(p => p.LikeCount)
|
||||
.ThenBy(p => p.CommentCount)
|
||||
.ThenBy(p => p.DateCreated);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
26
SieveUnitTests/Services/SieveOptionsAccessor.cs
Normal file
26
SieveUnitTests/Services/SieveOptionsAccessor.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using Sieve.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SieveUnitTests
|
||||
{
|
||||
public class SieveOptionsAccessor : IOptions<SieveOptions>
|
||||
{
|
||||
private SieveOptions _value;
|
||||
|
||||
public SieveOptions Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
|
||||
public SieveOptionsAccessor()
|
||||
{
|
||||
_value = new SieveOptions();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user