public async Task Should_Execute_Task_Continuation()
        {
            var successResult = SuccessResult <int, int> .Create(1);

            var failureResult = FailureResult <int, int> .Create(2);

            Assert.AreEqual(
                2,
                await successResult
                .OnSuccessAsync(s => Task.FromResult(s * 2))
                .OnFailureAsync(f => Task.FromResult(f * 5))
                .GetResultOrThrowExceptionAsync(f => new Exception()));
            Assert.AreEqual(
                2,
                await successResult
                .OnSuccessAsync(s => SuccessResult <int, int> .CreateAsync(s * 2))
                .OnFailureAsync(f => FailureResult <int, int> .CreateAsync(f * 5))
                .GetResultOrThrowExceptionAsync(f => new Exception()));
            Assert.AreEqual(
                4,
                await failureResult
                .OnFailureAsync(f => Task.FromResult(f * 2))
                .OnSuccessAsync(s => Task.FromResult(s * 5))
                .HandleAsync(s => 0, f => f));
            Assert.AreEqual(
                4,
                await failureResult
                .OnFailureAsync(f => FailureResult <int, int> .CreateAsync(f * 2))
                .OnSuccessAsync(s => SuccessResult <int, int> .CreateAsync(s * 5))
                .HandleAsync(s => 0, f => f));
        }
        public async Task Should_Get_Async_Result_When_Available()
        {
            var result = "result";
            var failableAsyncResult = SuccessResult <string, bool> .CreateAsync(result);

            Assert.AreEqual(result, await failableAsyncResult.GetResultOrThrowExceptionAsync(f => new Exception()));
        }
        public async Task Should_Create_Success_Async_Result_When_Factory_Method_Used()
        {
            var result             = "success";
            var successAsyncResult = SuccessResult <string, bool> .CreateAsync(result);

            var successResult = await successAsyncResult;

            Assert.AreEqual(result, (successResult as SuccessResult <string, bool>).Result);
        }
        public async Task Should_handle_async_result_with_async_continuations()
        {
            var asyncSuccessResult = SuccessResult <int, int> .CreateAsync(1);

            var asyncFailureResult = FailureResult <int, int> .CreateAsync(1);

            Func <int, Task <int> > f1 = x => Task.FromResult(x * 2);
            Func <int, Task <int> > f2 = x => Task.FromResult(-x);
            var handledSuccessResult   = await asyncSuccessResult.HandleAsync(f1, f2);

            var handledFailureResult = await asyncFailureResult.HandleAsync(f1, f2);

            Assert.AreEqual(2, handledSuccessResult);
            Assert.AreEqual(-1, handledFailureResult);
        }
        public async Task Should_handle_async_result()
        {
            var asyncSuccessResult = SuccessResult <int, int> .CreateAsync(1);

            var asyncFailureResult = FailureResult <int, int> .CreateAsync(1);

            Func <int, int> f1 = x => x * 2;
            Func <int, int> f2 = x => - x;
            var             handledSuccessResult = await asyncSuccessResult.HandleAsync(f1, f2);

            var handledFailureResult = await asyncFailureResult.HandleAsync(f1, f2);

            Assert.AreEqual(2, handledSuccessResult);
            Assert.AreEqual(-1, handledFailureResult);
        }