fix in the order of sortings when grouping is activated.
This commit is contained in:
parent
39be955fcc
commit
99e623c93f
@ -52,6 +52,62 @@ namespace PoweredSoft.DynamicQuery.Test
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
MockContextFactory.SeedAndTestContextFor("GroupTests_A", TestSeeders.SeedTicketScenario, ctx =>
|
||||||
|
{
|
||||||
|
var a = ctx.Tickets
|
||||||
|
.OrderBy(t => t.Owner)
|
||||||
|
.ThenBy(t => t.Priority)
|
||||||
|
.Skip(0)
|
||||||
|
.Take(100)
|
||||||
|
.GroupBy(t => new
|
||||||
|
{
|
||||||
|
t.Owner,
|
||||||
|
t.Priority
|
||||||
|
})
|
||||||
|
.Select(t => new
|
||||||
|
{
|
||||||
|
t.Key.Owner,
|
||||||
|
t.Key.Priority,
|
||||||
|
Records = t.ToList()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
int breakHere = 0;
|
||||||
|
});*/
|
||||||
|
|
||||||
|
MockContextFactory.SeedAndTestContextFor("GroupTests_A2", TestSeeders.SeedTicketScenario, ctx =>
|
||||||
|
{
|
||||||
|
var criteria = new QueryCriteria()
|
||||||
|
{
|
||||||
|
Groups = new List<IGroup>()
|
||||||
|
{
|
||||||
|
new Group { Path = "Owner" },
|
||||||
|
new Group { Path = "Priority" }
|
||||||
|
},
|
||||||
|
Page = 1,
|
||||||
|
PageSize = 100
|
||||||
|
};
|
||||||
|
|
||||||
|
var queryHandler = new QueryHandler();
|
||||||
|
var result = queryHandler.Execute(ctx.Tickets, criteria);
|
||||||
|
|
||||||
|
var groupedResult = result.GroupedResult();
|
||||||
|
|
||||||
|
var firstGroup = groupedResult.Groups.FirstOrDefault();
|
||||||
|
Assert.NotNull(firstGroup);
|
||||||
|
var secondGroup = groupedResult.Groups.Skip(1).FirstOrDefault();
|
||||||
|
Assert.NotNull(secondGroup);
|
||||||
|
|
||||||
|
var expected = ctx.Tickets.Select(t => t.TicketType).Distinct().Count();
|
||||||
|
var c = groupedResult.Groups.Select(t => t.GroupValue).Count();
|
||||||
|
Assert.Equal(expected, c);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GroupComplex()
|
public void GroupComplex()
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,14 @@ namespace PoweredSoft.DynamicQuery.Test.Mock
|
|||||||
{
|
{
|
||||||
MockContextFactory.TestContextFor(testName, ctx =>
|
MockContextFactory.TestContextFor(testName, ctx =>
|
||||||
{
|
{
|
||||||
|
var owners = new List<string>();
|
||||||
|
|
||||||
|
for(var i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
var f = new Bogus.Faker("en");
|
||||||
|
owners.Add(f.Person.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
var faker = new Bogus.Faker<Ticket>()
|
var faker = new Bogus.Faker<Ticket>()
|
||||||
.RuleFor(t => t.TicketType, (f, u) => f.PickRandom("new", "open", "refused", "closed"))
|
.RuleFor(t => t.TicketType, (f, u) => f.PickRandom("new", "open", "refused", "closed"))
|
||||||
.RuleFor(t => t.Title, (f, u) => f.Lorem.Sentence())
|
.RuleFor(t => t.Title, (f, u) => f.Lorem.Sentence())
|
||||||
@ -104,8 +112,8 @@ namespace PoweredSoft.DynamicQuery.Test.Mock
|
|||||||
.RuleFor(t => t.IsHtml, (f, u) => false)
|
.RuleFor(t => t.IsHtml, (f, u) => false)
|
||||||
.RuleFor(t => t.TagList, (f, u) => string.Join(",", f.Commerce.Categories(3)))
|
.RuleFor(t => t.TagList, (f, u) => string.Join(",", f.Commerce.Categories(3)))
|
||||||
.RuleFor(t => t.CreatedDate, (f, u) => f.Date.Recent(100))
|
.RuleFor(t => t.CreatedDate, (f, u) => f.Date.Recent(100))
|
||||||
.RuleFor(t => t.Owner, (f, u) => f.Person.FullName)
|
.RuleFor(t => t.Owner, (f, u) => f.PickRandom(owners))
|
||||||
.RuleFor(t => t.AssignedTo, (f, u) => f.Person.FullName)
|
.RuleFor(t => t.AssignedTo, (f, u) => f.PickRandom(owners))
|
||||||
.RuleFor(t => t.TicketStatus, (f, u) => f.PickRandom(1, 2, 3))
|
.RuleFor(t => t.TicketStatus, (f, u) => f.PickRandom(1, 2, 3))
|
||||||
.RuleFor(t => t.LastUpdateBy, (f, u) => f.Person.FullName)
|
.RuleFor(t => t.LastUpdateBy, (f, u) => f.Person.FullName)
|
||||||
.RuleFor(t => t.LastUpdateDate, (f, u) => f.Date.Soon(5))
|
.RuleFor(t => t.LastUpdateDate, (f, u) => f.Date.Soon(5))
|
||||||
|
@ -37,7 +37,7 @@ namespace PoweredSoft.DynamicQuery
|
|||||||
var aggregateResults = FetchAggregates<TSource>(finalGroups);
|
var aggregateResults = FetchAggregates<TSource>(finalGroups);
|
||||||
|
|
||||||
// sorting.
|
// sorting.
|
||||||
finalGroups.ForEach(fg => Criteria.Sorts.Insert(0, new Sort(fg.Path, fg.Ascending)));
|
finalGroups.ReversedForEach(fg => Criteria.Sorts.Insert(0, new Sort(fg.Path, fg.Ascending)));
|
||||||
|
|
||||||
// apply sorting and paging.
|
// apply sorting and paging.
|
||||||
ApplySorting<TSource>();
|
ApplySorting<TSource>();
|
||||||
|
@ -44,7 +44,7 @@ namespace PoweredSoft.DynamicQuery
|
|||||||
var aggregateResults = await FetchAggregatesAsync<TSource>(finalGroups, cancellationToken);
|
var aggregateResults = await FetchAggregatesAsync<TSource>(finalGroups, cancellationToken);
|
||||||
|
|
||||||
// sorting.
|
// sorting.
|
||||||
finalGroups.ForEach(fg => Criteria.Sorts.Insert(0, new Sort(fg.Path, fg.Ascending)));
|
finalGroups.ReversedForEach(fg => Criteria.Sorts.Insert(0, new Sort(fg.Path, fg.Ascending)));
|
||||||
|
|
||||||
// apply sorting and paging.
|
// apply sorting and paging.
|
||||||
ApplySorting<TSource>();
|
ApplySorting<TSource>();
|
||||||
|
Loading…
Reference in New Issue
Block a user