public FractionalCurrency(Currency parent, decimal epsilon, string code) { Require.Range(0m < epsilon && epsilon < 1m, nameof(epsilon)); Require.NotNull(code, nameof(code)); Parent = parent; Epsilon = epsilon; Code = code; }
public static void Range1() { Action act = () => { Require.Range(true, "paramName"); Require.Range(true, "paramName", "My message"); }; Assert.DoesNotThrow(act); }
public static void Range2() { var paramName = "paramName"; Action act = () => Require.Range(false, paramName); var ex = Record.Exception(act); Assert.NotNull(ex); Assert.NotNull(ex.Message); var argex = Assert.IsType <ArgumentOutOfRangeException>(ex); Assert.Equal(paramName, argex.ParamName); }
public static void Range3() { var paramName = "paramName"; var message = "My message"; Action act = () => Require.Range(false, paramName, message); var ex = Record.Exception(act); Assert.NotNull(ex); var argex = Assert.IsType <ArgumentOutOfRangeException>(ex); Assert.Equal(paramName, argex.ParamName); // NB: ArgumentOutOfRangeException appends some info to our message. Assert.StartsWith(message, ex.Message, StringComparison.OrdinalIgnoreCase); }
public static void Range_ThrowsArgumentOutOfRangeException_ForFalse_1() { Assert.Throws <ArgumentOutOfRangeException>(() => Require.Range(false, "paramName")); // Arrange var paramName = "paramName"; Action act = () => Require.Range(false, paramName); // Act var ex = Record.Exception(act); // Assert Assert.NotNull(ex); Assert.NotNull(ex.Message); var argex = Assert.IsType <ArgumentOutOfRangeException>(ex); Assert.Equal(paramName, argex.ParamName); }
public static string ToFlickrBase58String(long value) { Require.Range(value >= 0L, nameof(value)); return(Encode(value, s_FlickrBase58Alphabet, BASE58_ALPHABET_LENGTH, BASE58_MAX_LENGTH)); }
public static string ToBase34String(long value) { Require.Range(value >= 0L, nameof(value)); return(Encode(value, s_Base34Alphabet, BASE34_ALPHABET_LENGTH, BASE34_MAX_LENGTH)); }
public static void Range_DoesNotThrow_ForTrue_2() => Require.Range(true, "paramName", "My message");
public static void Range_DoesNotThrow_ForTrue_1() => Require.Range(true, "paramName");