sort interceptors.
This commit is contained in:
parent
5309fc7a50
commit
486200ea6c
43
PoweredSoft.DynamicQuery.Test/SortInterceptorTests.cs
Normal file
43
PoweredSoft.DynamicQuery.Test/SortInterceptorTests.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using PoweredSoft.DynamicQuery.Core;
|
||||
using PoweredSoft.DynamicQuery.Test.Mock;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace PoweredSoft.DynamicQuery.Test
|
||||
{
|
||||
public class SortInterceptorTests
|
||||
{
|
||||
private class MockSortInterceptor : ISortInterceptor
|
||||
{
|
||||
public IEnumerable<ISort> InterceptSort(IEnumerable<ISort> sort)
|
||||
{
|
||||
return new Sort[]
|
||||
{
|
||||
new Sort("Customer.FirstName"),
|
||||
new Sort("Customer.LastName")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Simple()
|
||||
{
|
||||
MockContextFactory.SeedAndTestContextFor("SortInterceptorTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
|
||||
{
|
||||
// expected
|
||||
var expected = ctx.Orders.OrderBy(t => t.Customer.FirstName).ThenBy(t => t.Customer.LastName).ToList();
|
||||
|
||||
// criteria
|
||||
var criteria = new QueryCriteria();
|
||||
criteria.Sorts.Add(new Sort("CustomerFullName"));
|
||||
var queryHandler = new QueryHandler();
|
||||
queryHandler.AddInterceptor(new MockSortInterceptor());
|
||||
var result = queryHandler.Execute(ctx.Orders, criteria);
|
||||
Assert.Equal(expected, result.Data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -98,8 +98,8 @@ INoSortInterceptor<T> | [interface](../master/PoweredSoft.Dynam
|
||||
|
||||
Interceptor | Interface | Example | Description
|
||||
----------------------|------------------------------------------------------------------------------------|-------------------------------------------------------------|---------------------------------------------------------------------------------------------------
|
||||
IFilterInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/IFilterInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IFilter being applied to the queryable
|
||||
ISortInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/ISortInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a ISort being applied to the queryable
|
||||
IFilterInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/IFilterInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/FilterInterceptorTests.cs) | This interceptor allows you to change the behavior of a IFilter being applied to the queryable
|
||||
ISortInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/ISortInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/SortInterceptorTests.cs) | This interceptor allows you to change the behavior of a ISort being applied to the queryable
|
||||
IGroupInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/IGroupInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IGroup being applied to the queryable
|
||||
IAggregateInterceptor | [interface](../master/PoweredSoft.DynamicQuery.Core/IAggregateInterceptor.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IAggregate being applied to the queryable
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user