Fix for Issue #19

This commit is contained in:
David Bond
2018-05-15 00:34:37 +01:00
parent afbd41e090
commit 204a1b55e2
39 changed files with 379 additions and 504 deletions

View File

@@ -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)
{
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}
}

View File

@@ -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
};