public static void ValueOrThrow_ReturnsValue_IfSuccess() { var exp = new Obj(); var ok = Fallible.Of(exp); Assert.Same(exp, ok.ValueOrThrow()); }
public static void Deconstruct2() { var nok = Fallible.FromError(Error); var(succeed, err) = nok; Assert.False(succeed); Assert.Same(Error, err); }
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); }
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)); }
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)); }
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); }
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); }
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); }
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); }
public static void ValueOrDefault_ReturnsDefault_IfError() { var nok = Fallible <Obj> .FromError(Error); Assert.Same(default(Obj), nok.ValueOrDefault()); }