Beispiel #1
0
        /// <summary>
        /// Constrains the <see cref="CancellationToken"/> argument to be not canceled (<c>IsCancellationRequested</c> is false).
        /// </summary>
        /// <param name="manager">The constraint manager.</param>
        /// <returns>A dummy argument value.</returns>
        public static CancellationToken IsNotCanceled(this INegatableArgumentConstraintManager <CancellationToken> manager)
        {
            Guard.AgainstNull(manager, nameof(manager));

            return(manager.Matches(
                       token => !token.IsCancellationRequested,
                       x => x.Write("non-canceled cancellation token")));
        }
Beispiel #2
0
 public static HashSet <T> Is <T>(this INegatableArgumentConstraintManager <HashSet <T> > that, params T[]?values)
 {
     return(values == null?that.IsNull() : that.Matches(x => x.Intersect(values).Count() == values.Length));
 }
Beispiel #3
0
 public static ClrQuery Is(this INegatableArgumentConstraintManager <ClrQuery> that, string query)
 {
     return(that.Matches(x => x.ToString() == query));
 }
Beispiel #4
0
 public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, IEnumerable <DomainId> ids)
 {
     return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids.ToHashSet())));
 }
Beispiel #5
0
 public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, params DomainId[] ids)
 {
     return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids)));
 }
Beispiel #6
0
 public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string odata, DomainId reference = default)
 {
     return(that.Matches(x => x.ODataQuery == odata && x.Reference == reference));
 }
Beispiel #7
0
        public static T?IsNotNull <T>(this INegatableArgumentConstraintManager <T?> manager) where T : struct
        {
            Guard.AgainstNull(manager, nameof(manager));

            return(manager.Matches(x => x != null, x => x.Write("NOT NULL")));
        }
        /// <summary>
        /// Constrains an argument so that it must not be null (Nothing in VB).
        /// </summary>
        /// <typeparam name="T">The type of the argument.</typeparam>
        /// <param name="manager">The constraint manager to match the constraint.</param>
        /// <returns>A dummy argument value.</returns>
        public static T IsNotNull <T>(this INegatableArgumentConstraintManager <T> manager) where T : class
        {
            Guard.AgainstNull(manager, nameof(manager));

            return(manager.Matches(x => x is object, x => x.Write("NOT NULL")));
        }
Beispiel #9
0
        protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
        {
            Guard.AgainstNull(scope, nameof(scope));

            scope.Matches(x => x == null || x == "foo", x => x.Write("string that is \"foo\" or is empty"));
        }
Beispiel #10
0
 public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string query)
 {
     return(that.Matches(x => x.ODataQuery == query));
 }