public static Rule BeGreaterThan <T>(T requirement) where T : IComparable <T>
        {
            if (requirement == null)
            {
                throw new ArgumentNullException("requirement");
            }

            return(MakeRule.That <T>(v => v.CompareTo(requirement) > 0)
                   .OrCreateArgumentOutOfRangeException()
                   .Because($"Value must be greater than {requirement}."));
        }
        public static Rule BeLessThanOrEqualTo <T>(T requirement) where T : IComparable <T>
        {
            if (requirement == null)
            {
                throw new ArgumentNullException("requirement");
            }

            return(MakeRule.That <T>(v => v.CompareTo(requirement) <= 0)
                   .OrCreateArgumentOutOfRangeException()
                   .Because($"Value must be less than or equal to {requirement}."));
        }
        public static Rule BeInRange <T>(T minimum, T maximum) where T : IComparable <T>
        {
            if (minimum == null)
            {
                throw new ArgumentNullException("minimum");
            }

            if (maximum == null)
            {
                throw new ArgumentNullException("maximum");
            }

            return(MakeRule.That <T>(v => v.CompareTo(minimum) >= 0 && v.CompareTo(maximum) <= 0)
                   .OrCreateArgumentOutOfRangeException()
                   .Because($"Value must range from {minimum} to {maximum}."));
        }
 public static Rule NotBeEmptyEnumerable <T>()
 {
     return(MakeRule.That <IEnumerable <T> >(e => e != null && e.Any())
            .OrCreateArgumentException()
            .Because("Enumeration cannot be null or empty."));
 }
 public static Rule NotBeDefault <T>() where T : IEquatable <T>
 {
     return(MakeRule.That <T>(v => v != null && !v.Equals(default(T)))
            .OrCreateArgumentException()
            .Because($"Value must be not be null or {default(T)}"));
 }
 public static Rule BeEqualTo <T>(T requirement)
 {
     return(MakeRule.That <T>(v => EqualityComparer <T> .Default.Equals(v, requirement))
            .OrCreateArgumentException()
            .Because($"Value must be equal to {requirement}."));
 }
 public static Rule NotContainElement <T>(T element)
 {
     return(MakeRule.That <IEnumerable <T> >(e => e != null && !e.Contains(element))
            .OrCreateArgumentException()
            .Because($"Enumeration cannot be null or contain {element}."));
 }
 public static Rule NotContainAnyNulls <T>()
 {
     return(MakeRule.That <IEnumerable <T> >(e => e != null && e.All(i => i != null))
            .OrCreateArgumentException()
            .Because("Enumeration cannot be null or contain any nulls."));
 }