// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using System.Collections.Generic; using System.Linq; using FakeItEasy; using Squidex.Infrastructure.Queries; namespace Squidex.Domain.Apps.Entities.TestHelpers { public static class AExtensions { public static Q HasQuery(this INegatableArgumentConstraintManager that, string query) { return that.Matches(x => x.Query!.ToString() == query); } public static Q HasOData(this INegatableArgumentConstraintManager that, string query) { return that.Matches(x => x.ODataQuery == query); } public static ClrQuery Is(this INegatableArgumentConstraintManager that, string query) { return that.Matches(x => x.ToString() == query); } public static T[] Is(this INegatableArgumentConstraintManager that, params T[]? values) { return values == null ? that.IsNull() : that.IsSameSequenceAs(values); } public static HashSet Is(this INegatableArgumentConstraintManager> that, IEnumerable? values) { return values == null ? that.IsNull() : that.Matches(x => x.Intersect(values).Count() == values.Count()); } public static HashSet Is(this INegatableArgumentConstraintManager> that, params T[]? values) { return values == null ? that.IsNull() : that.Matches(x => x.Intersect(values).Count() == values.Length); } } }