Пример #1
0
        public async Task Finally_LeftAsync_unit_result_E_executes_on_failure_returns_K()
        {
            UnitResult <E> result = UnitResult.Failure(E.Value);
            K output = await result.AsTask().Finally(Func_Unit_Result_E);

            AssertCalled(result, output);
        }
Пример #2
0
        public async Task Finally_LeftAsync_unit_result_E_executes_on_success_returns_K()
        {
            UnitResult <E> result = UnitResult.Success <E>();
            K output = await result.AsTask().Finally(Func_Unit_Result_E);

            AssertCalled(result, output);
        }
        public void Bind_E_returns_unit_result_failure_and_does_not_execute_func()
        {
            UnitResult <E> input = UnitResult.Failure(E.Value);

            UnitResult <E> output = input.AsTask().Bind(GetUnitResult_E_Task).Result;

            AssertFailure(output);
        }
        public void Bind_E_selects_new_unit_result()
        {
            UnitResult <E> input = UnitResult.Success <E>();

            UnitResult <E> output = input.AsTask().Bind(GetUnitResult_E_Task).Result;

            AssertSuccess(output);
        }
        public void Tap_unit_result_E_executes_action_on_failure_and_returns_self()
        {
            UnitResult <E> result = UnitResult.Failure(E.Value);

            var returned = result.AsTask().Tap(Action).Result;

            actionExecuted.Should().Be(false);
            result.Should().Be(returned);
        }
        public void Tap_unit_result_E_executes_action_on_success_and_returns_self()
        {
            UnitResult <E> result = UnitResult.Success <E>();

            var returned = result.AsTask().Tap(Action).Result;

            actionExecuted.Should().Be(true);
            result.Should().Be(returned);
        }
Пример #7
0
        public async Task OnFailure_AsyncLeft_unit_result_E_executes_E_action_on_failure_and_returns_self(bool isSuccess)
        {
            UnitResult <E> result = UnitResult.SuccessIf(isSuccess, E.Value);

            UnitResult <E> returned = await result.AsTask().OnFailure(ActionError);

            actionExecuted.Should().Be(!isSuccess);
            result.Should().Be(returned);
        }