Example #1
0
 public static void IsNotNull(this IGuaranteeThat guarantee, object input, string parameterName = null)
 {
     if (null == input)
     {
         throw Guarantee.ExceptionFactory.ArgumentNullException("", parameterName);
     }
 }
Example #2
0
 public static void IsFalse(this IGuaranteeThat guarantee, bool input, string parameterName = null)
 {
     if (input)
     {
         throw Guarantee.ExceptionFactory.ArgumentException("", parameterName);
     }
 }
Example #3
0
        public static void IsNotNullOrEmpty(this IGuaranteeThat guarantee, string input, string parameterName = null)
        {
            guarantee.IsNotNull(input);

            if (string.IsNullOrEmpty(input))
            {
                throw Guarantee.ExceptionFactory.ArgumentNullException("", parameterName);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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);
            }
        }