예제 #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")));
        }
예제 #2
0
        public static T[] Is <T>(this INegatableArgumentConstraintManager <T[]> that, params T[] values)
        {
            if (values == null)
            {
                return(that.IsNull());
            }

            return(that.IsSameSequenceAs(values));
        }
예제 #3
0
 public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, IEnumerable <DomainId> ids)
 {
     return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids.ToHashSet())));
 }
 protected override void CreateConstraint(INegatableArgumentConstraintManager <int?> scope) => scope.IsNotNull();
예제 #5
0
 public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, params DomainId[] ids)
 {
     return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids)));
 }
예제 #6
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <int> > scope)
 {
     scope.IsSameSequenceAs(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
 }
예제 #7
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope)
 {
     scope.IsInstanceOf(typeof(DateTime));
 }
예제 #8
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.IsNullOrEmpty();
 }
예제 #9
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope)
 {
     scope.IsNull();
 }
예제 #10
0
 public static ClrQuery Is(this INegatableArgumentConstraintManager <ClrQuery> that, string query)
 {
     return(that.Matches(x => x.ToString() == query));
 }
예제 #11
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <CancellationToken> scope)
 {
     scope.IsNotCanceled();
 }
예제 #12
0
 public static IEnumerable <T> Is <T>(this INegatableArgumentConstraintManager <IEnumerable <T> > that, params T[]?values)
 {
     return(values == null?that.IsNull() : that.IsSameSequenceAs(values));
 }
        /// <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")));
        }
예제 #14
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.Contains("bar");
 }
예제 #15
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.IsEqualTo("IgnoreCase", StringComparer.OrdinalIgnoreCase);
 }
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.Contains("BAR", StringComparison.OrdinalIgnoreCase);
 }
예제 #17
0
 protected abstract void CreateConstraint(INegatableArgumentConstraintManager <T> scope);
예제 #18
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <int> scope)
 {
     scope.IsGreaterThan(100);
 }
예제 #19
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));
 }
예제 #20
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")));
        }
예제 #21
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope)
 {
     scope.NullCheckedMatches(x => x is string, x => x.Write("is of type string"));
 }
예제 #22
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <string> > scope)
 {
     scope.IsSameSequenceAs("a", "b", null, "y", "z");
 }
예제 #23
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.EndsWith("table");
 }
예제 #24
0
        protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
        {
#pragma warning disable CA1307 // Specify StringComparison
            scope.EndsWith("table");
#pragma warning restore CA1307 // Specify StringComparison
        }
예제 #25
0
 protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <object> > scope)
 {
     scope.Contains(10);
 }
예제 #26
0
 public static Q HasQuery(this INegatableArgumentConstraintManager <Q> that, string query)
 {
     return(that.Matches(x => x.Query !.ToString() == query));
 }
 protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope)
 {
     scope.IsSameAs(TheRealThing);
 }
예제 #28
0
 public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string odata)
 {
     return(that.HasOData(odata, default));
 }
 protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope)
 {
     scope.EndsWith("TABLE", StringComparison.OrdinalIgnoreCase);
 }
예제 #30
0
 public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string odata, DomainId reference = default)
 {
     return(that.Matches(x => x.ODataQuery == odata && x.Reference == reference));
 }