예제 #1
0
        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;
        }
예제 #2
0
        public static void Range1()
        {
            Action act = () => {
                Require.Range(true, "paramName");
                Require.Range(true, "paramName", "My message");
            };

            Assert.DoesNotThrow(act);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        public static string ToFlickrBase58String(long value)
        {
            Require.Range(value >= 0L, nameof(value));

            return(Encode(value, s_FlickrBase58Alphabet, BASE58_ALPHABET_LENGTH, BASE58_MAX_LENGTH));
        }
예제 #7
0
        public static string ToBase34String(long value)
        {
            Require.Range(value >= 0L, nameof(value));

            return(Encode(value, s_Base34Alphabet, BASE34_ALPHABET_LENGTH, BASE34_MAX_LENGTH));
        }
예제 #8
0
 public static void Range_DoesNotThrow_ForTrue_2() => Require.Range(true, "paramName", "My message");
예제 #9
0
 public static void Range_DoesNotThrow_ForTrue_1() => Require.Range(true, "paramName");