示例#1
0
        public static void ValueOrThrow_ReturnsValue_IfSuccess()
        {
            var exp = new Obj();
            var ok  = Fallible.Of(exp);

            Assert.Same(exp, ok.ValueOrThrow());
        }
示例#2
0
        public static void Deconstruct2()
        {
            var nok = Fallible.FromError(Error);

            var(succeed, err) = nok;
            Assert.False(succeed);
            Assert.Same(Error, err);
        }
示例#3
0
        public static void Deconstruct2()
        {
            var nok = Fallible <Obj> .FromError(Error);

            var(succeed, value, err) = nok;
            Assert.False(succeed);
            Assert.Same(Error, err);
            Assert.Null(value);
        }
示例#4
0
        public static void ValueOrElse_ReturnsOther_IfError()
        {
            var nok = Fallible <Obj> .FromError(Error);

            var exp = new Obj();

            Assert.Same(exp, nok.ValueOrElse(exp));
            Assert.Same(exp, nok.ValueOrElse(() => exp));
        }
示例#5
0
        public static void ValueOrElse_ReturnsValue_IfSuccess()
        {
            var exp   = new Obj();
            var ok    = Fallible.Of(exp);
            var other = new Obj("other");

            Assert.Same(exp, ok.ValueOrElse(other));
            Assert.Same(exp, ok.ValueOrElse(() => other));
        }
示例#6
0
        public static void Deconstruct2()
        {
            var exp = new Obj();
            var nok = Result <string, Obj> .FromError(exp);

            var(succeed, value, err) = nok;
            Assert.False(succeed);
            Assert.Null(value);
            Assert.Same(exp, err);
        }
示例#7
0
        public static void Deconstruct1()
        {
            var exp = new Obj();
            var ok  = Result <Obj, string> .Of(exp);

            var(succeed, value, err) = ok;
            Assert.True(succeed);
            Assert.Same(exp, value);
            Assert.Null(err);
        }
示例#8
0
        public static void Deconstruct2()
        {
            var exp    = new Obj();
            var either = Either <int, Obj> .OfRight(exp);

            var(isLeft, left, right) = either;
            Assert.False(isLeft);
            Assert.Equal(default(int), left);
            Assert.Same(exp, right);
        }
示例#9
0
        public static void Deconstruct1()
        {
            var exp    = new Obj();
            var either = Either <Obj, int> .OfLeft(exp);

            var(isLeft, left, right) = either;
            Assert.True(isLeft);
            Assert.Same(exp, left);
            Assert.Equal(default(int), right);
        }
示例#10
0
        public static void ValueOrDefault_ReturnsDefault_IfError()
        {
            var nok = Fallible <Obj> .FromError(Error);

            Assert.Same(default(Obj), nok.ValueOrDefault());
        }