group testing.
This commit is contained in:
parent
5582b085c3
commit
247c50095a
51
PoweredSoft.DynamicQuery.Test/GroupTests.cs
Normal file
51
PoweredSoft.DynamicQuery.Test/GroupTests.cs
Normal file
@ -0,0 +1,51 @@
|
||||
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 GroupTests
|
||||
{
|
||||
[Fact]
|
||||
public void Simple()
|
||||
{
|
||||
MockContextFactory.SeedAndTestContextFor("GroupTests_Simple", TestSeeders.SimpleSeedScenario, ctx =>
|
||||
{
|
||||
var shouldResult = ctx.Orders.OrderBy(t => t.Customer).GroupBy(t => t.Customer).Select(t => new
|
||||
{
|
||||
Customer = t.Key,
|
||||
Orders = t.ToList()
|
||||
}).ToList();
|
||||
|
||||
// query handler that is empty should be the same as running to list.
|
||||
var criteria = new QueryCriteria()
|
||||
{
|
||||
Groups = new List<IGroup>
|
||||
{
|
||||
new Group { Path = "Customer" }
|
||||
}
|
||||
};
|
||||
|
||||
var queryHandler = new QueryHandler();
|
||||
var result = queryHandler.Execute(ctx.Orders, criteria);
|
||||
|
||||
// top level should have same amount of group levels.
|
||||
Assert.Equal(result.Data.Count, shouldResult.Count);
|
||||
for(var i = 0; i < shouldResult.Count; i++)
|
||||
{
|
||||
var expected = shouldResult[0];
|
||||
var actual = ((IGroupQueryResult)result.Data[0]);
|
||||
Assert.Equal(expected.Customer.Id, (actual.GroupValue as Customer).Id);
|
||||
|
||||
var expectedOrderIds = expected.Orders.Select(t => t.Id).ToList();
|
||||
var actualOrderIds = actual.Data.Cast<Order>().Select(t => t.Id).ToList();
|
||||
Assert.Equal(expectedOrderIds, actualOrderIds);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ Filter | [interface](../master/PoweredSoft.DynamicQuery.Core/IFilter.c
|
||||
Simple Filter | [interface](../master/PoweredSoft.DynamicQuery.Core/ISimpleFilter.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Filter.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/FilterTests.cs#L40) | Represent a simple filter to be executed
|
||||
Composite Filter | [interface](../master/PoweredSoft.DynamicQuery.Core/ICompositeFilter.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Filter.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/FilterTests.cs#L68) | Represent a composite filter to be executed
|
||||
Sort | [interface](../master/PoweredSoft.DynamicQuery.Core/ISort.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Sort.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/SortTests.cs#L15) | Represent a sort to be executed
|
||||
Group | [interface](../master/PoweredSoft.DynamicQuery.Core/IGroup.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Group.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent a group to be executed
|
||||
Group | [interface](../master/PoweredSoft.DynamicQuery.Core/IGroup.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Group.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/GroupTests.cs) | Represent a group to be executed
|
||||
Aggregate | [interface](../master/PoweredSoft.DynamicQuery.Core/IAggregate.cs) | [default implementation](../master/PoweredSoft.DynamicQuery/Aggregate.cs) | [test](../master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent an aggregate to be executed
|
||||
|
||||
### Sample
|
||||
|
Loading…
Reference in New Issue
Block a user