mirror of https://github.com/Squidex/squidex.git
Browse Source
* Improve content sorting using two stage aggregation framework. * Sorting improvements.pull/528/head
committed by
GitHub
12 changed files with 240 additions and 36 deletions
@ -0,0 +1,64 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Collections.Generic; |
|||
using Xunit; |
|||
|
|||
namespace Squidex.Infrastructure.Queries |
|||
{ |
|||
public class QueryTests |
|||
{ |
|||
[Fact] |
|||
public void Should_add_fields_from_sorting() |
|||
{ |
|||
var query = new ClrQuery |
|||
{ |
|||
Sort = new List<SortNode> |
|||
{ |
|||
new SortNode("field1", SortOrder.Ascending), |
|||
new SortNode("field1", SortOrder.Ascending), |
|||
new SortNode("field2", SortOrder.Ascending) |
|||
} |
|||
}; |
|||
|
|||
var fields = query.GetAllFields(); |
|||
|
|||
var expected = new HashSet<string> |
|||
{ |
|||
"field1", |
|||
"field2" |
|||
}; |
|||
|
|||
Assert.Equal(expected, fields); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_add_fields_from_filters() |
|||
{ |
|||
var query = new ClrQuery |
|||
{ |
|||
Filter = |
|||
ClrFilter.And( |
|||
ClrFilter.Not( |
|||
ClrFilter.Eq("field1", 1)), |
|||
ClrFilter.Or( |
|||
ClrFilter.Eq("field2", 2), |
|||
ClrFilter.Eq("field2", 4))) |
|||
}; |
|||
|
|||
var fields = query.GetAllFields(); |
|||
|
|||
var expected = new HashSet<string> |
|||
{ |
|||
"field1", |
|||
"field2" |
|||
}; |
|||
|
|||
Assert.Equal(expected, fields); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue