Added case-insensitive operators and started unit tests project

This commit is contained in:
Biarity
2018-02-10 10:26:32 +10:00
parent aa6a836cfb
commit 2796197cc9
13 changed files with 356 additions and 88 deletions

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

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

View 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();
}
}
}