/// <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"))); }
public static T[] Is <T>(this INegatableArgumentConstraintManager <T[]> that, params T[] values) { if (values == null) { return(that.IsNull()); } return(that.IsSameSequenceAs(values)); }
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();
public static Q HasIds(this INegatableArgumentConstraintManager <Q> that, params DomainId[] ids) { return(that.Matches(x => x.Ids != null && x.Ids.SetEquals(ids))); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <int> > scope) { scope.IsSameSequenceAs(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope) { scope.IsInstanceOf(typeof(DateTime)); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { scope.IsNullOrEmpty(); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope) { scope.IsNull(); }
public static ClrQuery Is(this INegatableArgumentConstraintManager <ClrQuery> that, string query) { return(that.Matches(x => x.ToString() == query)); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <CancellationToken> scope) { scope.IsNotCanceled(); }
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"))); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { scope.Contains("bar"); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { scope.IsEqualTo("IgnoreCase", StringComparer.OrdinalIgnoreCase); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { scope.Contains("BAR", StringComparison.OrdinalIgnoreCase); }
protected abstract void CreateConstraint(INegatableArgumentConstraintManager <T> scope);
protected override void CreateConstraint(INegatableArgumentConstraintManager <int> scope) { scope.IsGreaterThan(100); }
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)); }
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"))); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <object> scope) { scope.NullCheckedMatches(x => x is string, x => x.Write("is of type string")); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <string> > scope) { scope.IsSameSequenceAs("a", "b", null, "y", "z"); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { scope.EndsWith("table"); }
protected override void CreateConstraint(INegatableArgumentConstraintManager <string> scope) { #pragma warning disable CA1307 // Specify StringComparison scope.EndsWith("table"); #pragma warning restore CA1307 // Specify StringComparison }
protected override void CreateConstraint(INegatableArgumentConstraintManager <IEnumerable <object> > scope) { scope.Contains(10); }
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); }
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); }
public static Q HasOData(this INegatableArgumentConstraintManager <Q> that, string odata, DomainId reference = default) { return(that.Matches(x => x.ODataQuery == odata && x.Reference == reference)); }