public static VerifyContext <string> IsNotEmpty(this VerifyContext <string> context, string?message = null) { if (string.IsNullOrWhiteSpace(context.Value)) { throw new ArgumentNullException(context.Format(message)); } return(context); }
public static VerifyContext <T> Assert <T>(this VerifyContext <T> context, Func <T, bool> assertOpr, string message) { if (!assertOpr(context.Value)) { throw new ArgumentException(context.Format(message)); } return(context); }
public static VerifyContext <T> Assert <T, TException>(this VerifyContext <T> context, Func <T, bool> assertOpr, string message) { if (!assertOpr(context.Value)) { throw (Exception)Activator.CreateInstance(typeof(TException), context.Format(message)); } return(context); }
public static VerifyContext <bool> Assert(this VerifyContext <bool> context, string message) { if (!context.Value) { throw new ArgumentException(context.Format(message)); } return(context); }
public static VerifyContext <T> IsNotNull <T>(this VerifyContext <T> context, string?message = null) { #pragma warning disable CS8653 // A default expression introduces a null value for a type parameter. if (EqualityComparer <T> .Default.Equals(context.Value, default)) { throw new ArgumentNullException(context.Format(message)); } #pragma warning restore CS8653 // A default expression introduces a null value for a type parameter. return(context); }