mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
// ==========================================================================
|
|
// 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);
|
|
}
|
|
}
|
|
}
|
|
|