public void AssertInRangeOnShortOutOfRangeThrowsArgumentOutOfRangeException(short sut, short min, short max) { var ex = Assert.Throws <ArgumentOutOfRangeException>(() => sut.AssertInRange(min, max, "sut")); Assert.Equal("sut", ex.ParamName); Assert.Equal(sut, ex.ActualValue); Assert.NotNull(ex.Message); var ex2 = Assert.Throws <ArgumentOutOfRangeException>(() => sut.AssertInRange(Interval <short> .Bounded(min, true, max, true), "sut")); Assert.Equal(ex.ParamName, ex2.ParamName); Assert.Equal(ex.ActualValue, ex2.ActualValue); Assert.Equal(ex.Message, ex2.Message); }
public void AssertInRangeOnShortInRangeDoesNotThrowException(short sut, short min, short max) { sut.AssertInRange(min, max, "sut"); sut.AssertInRange(Interval <short> .Bounded(min, true, max, true), "sut"); }
/// <summary> /// Ensures the numeric argument is within a range of values. /// </summary> /// <param name="arg">The argument.</param> /// <param name="min">The minimum value.</param> /// <param name="max">The maximum value.</param> /// <param name="paramName">The name of the parameter.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="arg"/> is less than <paramref name="min"/> or greater than <paramref name="max"/>. /// </exception> public static void AssertInRange(this short arg, short min, short max, string paramName) { arg.AssertInRange(Interval <short> .Bounded(min, true, max, true), paramName); }