Пример #1
0
        public static void Parse6b()
        {
            var value = "IBAN AL47212110090000000235698741";

            Assert.NotNull(Iban.Parse(value, IbanStyles.AllowHeader));
            Assert.True(Iban.TryParse(value, IbanStyles.AllowHeader).IsSuccess);
        }
Пример #2
0
        public static void OfRight1()
        {
            var either = Either <Obj, Obj> .OfRight(new Obj("left"));

            Assert.NotNull(either);
            Assert.True(either.IsRight);
            Assert.False(either.IsLeft);
        }
Пример #3
0
        public static void cast6()
        {
            var exp    = new Obj("right");
            var either = (Either <string, Obj>)exp;

            Assert.NotNull(either);
            Assert.True(either.IsRight);
            Assert.True(either.ContainsRight(exp));
        }
Пример #4
0
        public static void cast5()
        {
            var exp    = new Obj("left");
            var either = (Either <Obj, string>)exp;

            Assert.NotNull(either);
            Assert.True(either.IsLeft);
            Assert.True(either.ContainsLeft(exp));
        }
Пример #5
0
        public static void ThrowIfError2()
        {
            var nok = Fallible.FromError(Error);
            var ex  = Record.Exception(() => nok.ThrowIfError());

            Assert.NotNull(ex);
            Assert.IsType <SimpleException>(ex);
            Assert.Equal(ErrorMessage, ex.Message);
        }
Пример #6
0
        public static void ThrowIfError2()
        {
            var error = "My message";
            var nok   = Result <Obj, SimpleException> .FromError(new SimpleException(error));

            var ex = Record.Exception(() => nok.ThrowIfError());

            Assert.NotNull(ex);
            Assert.IsType <SimpleException>(ex);
            Assert.Equal(error, ex.Message);
        }
Пример #7
0
        public static void ValueOrThrow_Throws_IfError()
        {
            var nok = Fallible <Obj> .FromError(Error);

            Action act = () => nok.ValueOrThrow();
            var    ex  = Record.Exception(act);

            Assert.NotNull(ex);
            Assert.IsType <SimpleException>(ex);
            Assert.Equal(ErrorMessage, ex.Message);
        }
Пример #8
0
        public static void State3()
        {
            var    message = "My message";
            Action act     = () => Require.State(false, message);

            var ex = Record.Exception(act);

            Assert.NotNull(ex);
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal(message, ex.Message);
        }
Пример #9
0
        public static void True2()
        {
            var    paramName = "paramName";
            Action act       = () => Require.True(false, paramName);

            var ex = Record.Exception(act);

            Assert.NotNull(ex);
            Assert.NotNull(ex.Message);
            var argex = Assert.IsType <ArgumentException>(ex);

            Assert.Equal(paramName, argex.ParamName);
        }
Пример #10
0
        public static void NotNullOrWhiteSpace4()
        {
            var    paramName = "paramName";
            Action act       = () => Require.NotNullOrWhiteSpace(" ", paramName);

            var ex = Record.Exception(act);

            Assert.NotNull(ex);
            Assert.NotNull(ex.Message);
            var argex = Assert.IsType <ArgumentException>(ex);

            Assert.Equal(paramName, argex.ParamName);
        }
Пример #11
0
        public static void NotNullUnconstrained2()
        {
            Object obj       = null;
            var    paramName = "paramName";
            Action act       = () => Require.NotNullUnconstrained(obj, paramName);

            var ex = Record.Exception(act);

            Assert.NotNull(ex);
            Assert.NotNull(ex.Message);
            var argex = Assert.IsType <ArgumentNullException>(ex);

            Assert.Equal(paramName, argex.ParamName);
        }
Пример #12
0
        public static void True3()
        {
            var    paramName = "paramName";
            var    message   = "My message";
            Action act       = () => Require.True(false, paramName, message);

            var ex = Record.Exception(act);

            Assert.NotNull(ex);
            var argex = Assert.IsType <ArgumentException>(ex);

            Assert.Equal(paramName, argex.ParamName);
            // ArgumentException appends some info to our message.
            Assert.StartsWith(message, ex.Message, StringComparison.OrdinalIgnoreCase);
        }
Пример #13
0
 public static void Parse7b(string value)
 {
     Assert.NotNull(Iban.Parse(value, IbanStyles.Any));
     Assert.True(Iban.TryParse(value, IbanStyles.Any).IsSuccess);
 }
Пример #14
0
 public static void Parse5(string value)
 {
     Assert.NotNull(Iban.Parse(value, IbanStyles.AllowLowercaseLetter));
     Assert.True(Iban.TryParse(value, IbanStyles.AllowLowercaseLetter).IsSuccess);
 }
Пример #15
0
 public static void Parse4f(string value)
 {
     Assert.NotNull(Iban.Parse(value, IbanStyles.AllowInnerWhite));
     Assert.True(Iban.TryParse(value, IbanStyles.AllowInnerWhite).IsSuccess);
 }
Пример #16
0
 public static void Parse3(string value)
 {
     Assert.NotNull(Iban.Parse(value));
     Assert.True(Iban.TryParse(value).IsSuccess);
 }