private static PropertyMustBe <T, TValue> MustBePositive <T, TValue>(this PropertyMustBe <T, TValue> actual) where TValue : IComparable <TValue> { var expected = default(TValue); return(actual.CompareTo(expected).Is(Is.GreaterThan)); }
public static PropertyMustBe <T, TProp> MustBeLessThanOrEqualTo <T, TProp>( this PropertyMustBe <T, TProp> actual, TProp expected) where TProp : IComparable <TProp> { return(actual.CompareTo(expected).Is(Is.LessThanOrEqualTo)); }
public static PropertyMustBe <T, TProp> MustBeGreaterThan <T, TProp>( this PropertyMustBe <T, TProp> actual, TProp expected) where TProp : IComparable <TProp> { return(actual.CompareTo(expected).Is(Is.GreaterThan)); }
public static PropertyMustBe <T, TProp> MustBeInRange <T, TProp>( this PropertyMustBe <T, TProp> actual, TProp from, TProp to) where TProp : IComparable <TProp> { return(actual.RangedWith(from, to).Is(Is.InRange)); }
internal static PropertyMustBe <T, TProp> IsNot <T, TProp>( this PropertyMustBe <T, TProp> actual, Func <TProp, bool> comparer, [CallerMemberName] string mustBeMethod = null) { if (!comparer(actual.Value)) { return(actual); } throw new MustBeException <T, TProp>(actual, null, mustBeMethod); }
public static PropertyMustBe <T, TProp> SwitchTo <TOld, T, TProp>( this PropertyMustBe <TOld, T> @this, Expression <Func <T, TProp> > nextSelector) { var member = ((MemberExpression)nextSelector.Body).Member; if (member is PropertyInfo prop) { return(new PropertyMustBe <T, TProp>(@this.Value, prop.Name, (TProp)prop.GetValue(@this.Value))); } throw new MustBeException("Must.SwitchTo<TOld, T, TProp>() nextSelector must be a property selector."); }
public static PropertyMustBe <T, string> MustBe <T>(this PropertyMustBe <T, string> actual, string expected, Case @case) { switch (@case) { case Case.Sensitive: return(actual.ValidateWith(expected).Is(EqualSensitive)); case Case.Insensitive: return(actual.ValidateWith(expected).Is(EqualInsensitive)); default: throw new ArgumentOutOfRangeException(nameof(@case), @case, null); } }
internal static ToRange <T, TProp> RangedWith <T, TProp>(this PropertyMustBe <T, TProp> actual, TProp from, TProp to) where TProp : IComparable <TProp> { return(new ToRange <T, TProp>(actual, from, to)); }
public static PropertyMustBe <T, IList <TProp> > MustBeEmpty <T, TProp>(this PropertyMustBe <T, IList <TProp> > actual) { return(actual.ValidateWith(actual.Value).Is(x => x == null || !x.Any())); }
public static PropertyMustBe <T, bool?> MustBeFalse <T>(this PropertyMustBe <T, bool?> actual) { return(actual.ValidateWith(false).Is(Is.Equal)); }
public static PropertyMustBe <T, string> MustBeNullOrEmpty <T>(this PropertyMustBe <T, string> actual) { return(actual.Is(string.IsNullOrEmpty)); }
public static PropertyMustBe <T, bool> MustBeTrue <T>(this PropertyMustBe <T, bool> actual) { return(actual.ValidateWith(true).Is(Is.Equal)); }
public static PropertyMustBe <T, int> MustBePositive <T>(this PropertyMustBe <T, int> actual) { return(MustBePositive <T, int>(actual)); }
internal ToCompare(PropertyMustBe <T, TProp> actual, TProp expected) { Actual = actual; Expected = expected; }
public static PropertyMustBe <T, TProp[]> MustNotBeEmpty <T, TProp>(this PropertyMustBe <T, TProp[]> actual) { return(actual.ValidateWith(actual.Value).Is(x => x != null && x.Any())); }
public static PropertyMustBe <T, double> MustBeNegative <T>(this PropertyMustBe <T, double> actual) { return(MustBeNegative <T, double>(actual)); }
public static PropertyMustBe <T, float> MustBeNegative <T>(this PropertyMustBe <T, float> actual) { return(MustBeNegative <T, float>(actual)); }
public static PropertyMustBe <T, string> MustBeNullOrWhiteSpace <T>(this PropertyMustBe <T, string> actual) { return(actual.Is(string.IsNullOrWhiteSpace)); }
internal ToCompareEnumerable(PropertyMustBe <T, TProp> actual, IEnumerable <TProp> expected) { Actual = actual; Expected = expected; }
internal ToRange(PropertyMustBe <T, TProp> actual, TProp @from, TProp to) { Actual = actual; From = @from; To = to; }
public static PropertyMustBe <T, string> MustNotBe <T>(this PropertyMustBe <T, string> actual, string expected) { return(MustNotBe(actual, expected, Case.Insensitive)); }
public static PropertyMustBe <T, long> MustBeNegative <T>(this PropertyMustBe <T, long> actual) { return(MustBeNegative <T, long>(actual)); }
internal static ToComparable <T, TProp> CompareTo <T, TProp>(this PropertyMustBe <T, TProp> actual, TProp expected) where TProp : IComparable <TProp> { return(new ToComparable <T, TProp>(actual, expected)); }
public static PropertyMustBe <T, TProp> MustBe <T, TProp>(this PropertyMustBe <T, TProp> actual, TProp expected) { return(actual.ValidateWith(expected).Is(Is.Equal)); }
internal static ToCompareEnumerable <T, TProp> ValidateWith <T, TProp>( this PropertyMustBe <T, TProp> actual, IEnumerable <TProp> expected) { return(new ToCompareEnumerable <T, TProp>(actual, expected)); }
public static PropertyMustBe <T, decimal> MustBeNegative <T>(this PropertyMustBe <T, decimal> actual) { return(MustBeNegative <T, decimal>(actual)); }
public static PropertyMustBe <T, TProp> MustBeOneOf <T, TProp>(this PropertyMustBe <T, TProp> actual, params TProp[] expected) { return(actual.ValidateWith(expected).Is(Enumerable.Contains)); }