mirror of
https://github.com/Biarity/Sieve.git
synced 2025-09-20 07:09:43 +02:00
interface type fixes & unit test improvements
This commit is contained in:
@@ -16,62 +16,20 @@ namespace SieveUnitTests.Services
|
||||
{
|
||||
}
|
||||
|
||||
public SieveOptions ExposedOptions => new SieveOptions()
|
||||
{
|
||||
IgnoreNullsOnNotEqual = Options.Value.IgnoreNullsOnNotEqual,
|
||||
CaseSensitive = Options.Value.CaseSensitive,
|
||||
DefaultPageSize = Options.Value.DefaultPageSize,
|
||||
DisableNullableTypeExpressionForSorting = Options.Value.DisableNullableTypeExpressionForSorting,
|
||||
MaxPageSize = Options.Value.MaxPageSize,
|
||||
ThrowExceptions = Options.Value.ThrowExceptions,
|
||||
};
|
||||
|
||||
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
||||
{
|
||||
mapper.Property<Post>(p => p.ThisHasNoAttributeButIsAccessible)
|
||||
.CanSort()
|
||||
.CanFilter()
|
||||
.HasName("shortname");
|
||||
|
||||
mapper.Property<Post>(p => p.TopComment.Text)
|
||||
.CanFilter();
|
||||
|
||||
mapper.Property<Post>(p => p.TopComment.Id)
|
||||
.CanSort();
|
||||
|
||||
mapper.Property<Post>(p => p.OnlySortableViaFluentApi)
|
||||
.CanSort();
|
||||
|
||||
mapper.Property<Post>(p => p.TopComment.Text)
|
||||
.CanFilter()
|
||||
.HasName("topc");
|
||||
|
||||
mapper.Property<Post>(p => p.FeaturedComment.Text)
|
||||
.CanFilter()
|
||||
.HasName("featc");
|
||||
|
||||
mapper
|
||||
.Property<Post>(p => p.DateCreated)
|
||||
.CanSort()
|
||||
.HasName("CreateDate");
|
||||
|
||||
// interfaces
|
||||
mapper.Property<IPost>(p => p.ThisHasNoAttributeButIsAccessible)
|
||||
.CanSort()
|
||||
.CanFilter()
|
||||
.HasName("shortname");
|
||||
|
||||
mapper.Property<IPost>(p => p.TopComment.Text)
|
||||
.CanFilter();
|
||||
|
||||
mapper.Property<IPost>(p => p.TopComment.Id)
|
||||
.CanSort();
|
||||
|
||||
mapper.Property<IPost>(p => p.OnlySortableViaFluentApi)
|
||||
.CanSort();
|
||||
|
||||
mapper.Property<IPost>(p => p.TopComment.Text)
|
||||
.CanFilter()
|
||||
.HasName("topc");
|
||||
|
||||
mapper.Property<IPost>(p => p.FeaturedComment.Text)
|
||||
.CanFilter()
|
||||
.HasName("featc");
|
||||
|
||||
mapper
|
||||
.Property<IPost>(p => p.DateCreated)
|
||||
.CanSort()
|
||||
.HasName("CreateDate");
|
||||
SieveConfigurationForPost.ConfigureStatic(mapper);
|
||||
SieveConfigurationForIPost.ConfigureStatic(mapper);
|
||||
|
||||
return mapper;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Sieve.Services;
|
||||
using SieveUnitTests.Abstractions.Entity;
|
||||
using SieveUnitTests.Entities;
|
||||
@@ -8,9 +9,14 @@ namespace SieveUnitTests.Services
|
||||
{
|
||||
public class SieveCustomFilterMethods : ISieveCustomFilterMethods
|
||||
{
|
||||
internal static readonly Expression<Func<Post, bool>> IsNewFilterForPost = post => post.LikeCount < 100;
|
||||
internal static readonly Expression<Func<IPost, bool>> IsNewFilterForIPost = post => post.LikeCount < 100;
|
||||
internal static readonly Expression<Func<Comment, bool>> IsNewFilterForComment = comment => comment.DateCreated > DateTimeOffset.UtcNow.AddDays(-2);
|
||||
internal static readonly Expression<Func<IComment, bool>> IsNewFilterForIComment = comment => comment.DateCreated > DateTimeOffset.UtcNow.AddDays(-2);
|
||||
|
||||
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string[] values)
|
||||
{
|
||||
var result = source.Where(p => p.LikeCount < 100);
|
||||
var result = source.Where(IsNewFilterForPost);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -24,7 +30,7 @@ namespace SieveUnitTests.Services
|
||||
|
||||
public IQueryable<Comment> IsNew(IQueryable<Comment> source, string op, string[] values)
|
||||
{
|
||||
var result = source.Where(c => c.DateCreated > DateTimeOffset.UtcNow.AddDays(-2));
|
||||
var result = source.Where(IsNewFilterForComment);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -42,7 +48,7 @@ namespace SieveUnitTests.Services
|
||||
|
||||
public IQueryable<IPost> IsNew(IQueryable<IPost> source, string op, string[] values)
|
||||
{
|
||||
var result = source.Where(p => p.LikeCount < 100);
|
||||
var result = source.Where(IsNewFilterForIPost);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -56,7 +62,7 @@ namespace SieveUnitTests.Services
|
||||
|
||||
public IQueryable<IComment> IsNew(IQueryable<IComment> source, string op, string[] values)
|
||||
{
|
||||
var result = source.Where(c => c.DateCreated > DateTimeOffset.UtcNow.AddDays(-2));
|
||||
var result = source.Where(IsNewFilterForIComment);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user