mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-27 04:33:23 +02:00
Fix for Issue #19
This commit is contained in:
@@ -2,19 +2,15 @@
|
||||
using Sieve.Models;
|
||||
using Sieve.Services;
|
||||
using SieveUnitTests.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SieveUnitTests.Services
|
||||
{
|
||||
public class ApplicationSieveProcessor : SieveProcessor
|
||||
public class ApplicationSieveProcessor : SieveProcessor
|
||||
{
|
||||
public ApplicationSieveProcessor(
|
||||
IOptions<SieveOptions> options,
|
||||
ISieveCustomSortMethods customSortMethods,
|
||||
ISieveCustomFilterMethods customFilterMethods)
|
||||
IOptions<SieveOptions> options,
|
||||
ISieveCustomSortMethods customSortMethods,
|
||||
ISieveCustomFilterMethods customFilterMethods)
|
||||
: base(options, customSortMethods, customFilterMethods)
|
||||
{
|
||||
}
|
||||
|
@@ -1,24 +1,15 @@
|
||||
using Sieve.Services;
|
||||
using System.Linq;
|
||||
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);
|
||||
public IQueryable<Post> IsNew(IQueryable<Post> source)
|
||||
=> source.Where(p => p.LikeCount < 100);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IQueryable<Comment> TestComment(IQueryable<Comment> source, string op, string value)
|
||||
{
|
||||
return source;
|
||||
}
|
||||
public IQueryable<Comment> TestComment(IQueryable<Comment> source)
|
||||
=> source;
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,15 @@
|
||||
using Sieve.Services;
|
||||
using System.Linq;
|
||||
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)
|
||||
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy) => useThenBy
|
||||
? ((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount)
|
||||
: source.OrderBy(p => p.LikeCount)
|
||||
.ThenBy(p => p.CommentCount)
|
||||
.ThenBy(p => p.DateCreated);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,26 +1,15 @@
|
||||
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 SieveOptions Value { get; }
|
||||
|
||||
public SieveOptionsAccessor()
|
||||
{
|
||||
_value = new SieveOptions()
|
||||
Value = new SieveOptions()
|
||||
{
|
||||
ThrowExceptions = true
|
||||
};
|
||||
|
Reference in New Issue
Block a user