/// <summary> /// Validates that the specified argument is in a given range, range borders included. /// </summary> /// <typeparam name="T">The type of <paramref name="value"/>.</typeparam> /// <param name="value">The argument to check.</param> /// <param name="minInclusive">The minimum value (inclusive).</param> /// <param name="maxInclusive">The maximum value (inclusive).</param> /// <param name="parameterName">The name of the parameter.</param> /// <exception cref="ArgumentException">Thrown if <paramref name="minInclusive"/> is greater than /// or equal to <paramref name="maxInclusive"/>.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is outside /// the allowable range of values.</exception> public static void Range <T>(T value, T minInclusive, T maxInclusive, string parameterName) where T : struct, IComparable <T> { // We only accept generics of value type; adding reference types would make // each method check too many things at a time (null-checks). Expect.True(minInclusive.CompareTo(maxInclusive) <= 0); Expect.NotNullOrEmpty(parameterName); if (value.CompareTo(minInclusive) < 0 || value.CompareTo(maxInclusive) > 0) { throw new ArgumentOutOfRangeException( parameterName, value, String.Format( CultureInfo.CurrentCulture, Strings.ArgumentOutOfRange, parameterName, minInclusive, maxInclusive)); } }
public static void True_Passes_ForFalse() => Expect.True(false);
public static void True_Passes_ForTrue() => Expect.True(true);