public static void IsNotNull(this IGuaranteeThat guarantee, object input, string parameterName = null) { if (null == input) { throw Guarantee.ExceptionFactory.ArgumentNullException("", parameterName); } }
public static void IsFalse(this IGuaranteeThat guarantee, bool input, string parameterName = null) { if (input) { throw Guarantee.ExceptionFactory.ArgumentException("", parameterName); } }
public static void IsNotNullOrEmpty(this IGuaranteeThat guarantee, string input, string parameterName = null) { guarantee.IsNotNull(input); if (string.IsNullOrEmpty(input)) { throw Guarantee.ExceptionFactory.ArgumentNullException("", parameterName); } }
public static void IsOfType <TExpected>(this IGuaranteeThat guarantee, object input, string parameterName = null) { Guarantee.That.IsNotNull(input, parameterName); if (input.GetType() != typeof(TExpected)) { throw Guarantee.ExceptionFactory.ArgumentException( "", parameterName); } }
public static void IsOfType(this IGuaranteeThat guarantee, object input, Type expectedType, string parameterName = null) { Guarantee.That.IsNotNull(input, parameterName); Guarantee.That.IsNotNull(expectedType, nameof(expectedType)); if (input.GetType() != expectedType) { throw Guarantee.ExceptionFactory.ArgumentException( "", parameterName); } }
public static IEnumerable <T> HasItems <T>(this IGuaranteeThat guarantee, IEnumerable <T> value, string parameterName = null) { Guarantee.That.IsNotNull(value, parameterName); if (value.Count() == 0) { throw Guarantee.ExceptionFactory.ArgumentException( "", parameterName); } return(value); }
public static void SizeIsGte <T>(this IGuaranteeThat guarantee, IEnumerable <T> value, int expected, string parameterName = null) { Guarantee.That.IsNotNull(value, parameterName); var count = value.Count(); if (count < expected) { throw Guarantee.ExceptionFactory.ArgumentException( "", parameterName); } }