/// <summary> /// Checks whether the value is smaller or equal to the reference value. /// </summary> /// <param name="value">The value to test.</param> /// <param name="referenceValue">The reference value to test.</param> /// <exception cref="ArgumentOutOfRangeException"><em>value</em> is out of /// range.</exception> public static void IsSmallerOrEqual(IComparable value, IComparable referenceValue) { if (!value.IsSmallerOrEqual(referenceValue)) { throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Checks whether the value is smaller or equal to the reference value. /// </summary> /// <param name="value">The value to test.</param> /// <param name="referenceValue">The reference value to test.</param> /// <param name="paramName">The name of the parameter that caused the exception.</param> /// <param name="message">A message that describes the error.</param> /// <exception cref="ArgumentOutOfRangeException"><em>value</em> is out of /// range.</exception> public static void IsSmallerOrEqual(IComparable value, IComparable referenceValue, string paramName, string message) { if (!value.IsSmallerOrEqual(referenceValue)) { throw new ArgumentOutOfRangeException(paramName, referenceValue, message); } }
/// <summary> /// Indicates whether the instance is between a minimum and maximum value. /// </summary> /// <param name="value">The instance to test.</param> /// <param name="min">The minimum value to test.</param> /// <param name="max">The maximum value to test.</param> /// <returns><strong>true</strong> if the instance is between the minimum and maximum /// value; otherwise, <strong>false</strong>.</returns> /// <exception cref="ArgumentNullException"><em>value</em>, <em>min</em> or <em>max</em> is /// <strong>null</strong>.</exception> public static bool IsBetween(this IComparable value, IComparable min, IComparable max) { Precondition.IsNotNull(value, nameof(value)); Precondition.IsNotNull(min, nameof(min)); Precondition.IsNotNull(max, nameof(max)); return(value.IsGreaterOrEqual(min) && value.IsSmallerOrEqual(max)); }
public void IsSmallerOrEqual_Throws_ArgumentNullException(IComparable value, IComparable referenceValue, string expectedParameter) { AssertThrowsException<ArgumentNullException>(() => value.IsSmallerOrEqual(referenceValue), expectedParameter); }
public void IsSmallerOrEqual_Throws_ArgumentNullException(IComparable value, IComparable referenceValue, string expectedParameter) { AssertThrowsException <ArgumentNullException>(() => value.IsSmallerOrEqual(referenceValue), expectedParameter); }