示例#1
0
        public static Nothing Otherwise(this bool self, Action action)
        {
            if (self is false)
            {
                action();
            }

            return(Nothing.Of());
        }
示例#2
0
        public void Should_Run_Success_Given_A_Value()
        {
            var nothing = Nothing.Of();

            var failable =
                nothing
                .Do(() => Failable.From("success"))
                .Match(
                    success: (value) => Assert.True(true), // pass
                    failure: (error) => throw error        // fail
                    );
        }
示例#3
0
        public void Should_Run_Failure_Given_Failure_Value()
        {
            var nothing = Nothing.Of();

            var failable =
                nothing
                .Do(() => Failable.FromException <string>(new Exception("It could not create a failable")))
                .Match(
                    success: (value) => throw new Exception("Test has failed. It should run failure"),    // fail
                    failure: (error) => Assert.Equal("It could not create a failable", error.Message)     // pass
                    );
        }