Example #1
0
        public void Combine_if_all_results_are_ok_returns_ok_result()
        {
            var resultsLists = new List <HttpResult>
            {
                HttpResult.Ok(),
                HttpResult.Ok(),
                HttpResult.Ok()
            };

            var combinedResult = HttpResult.Combine(resultsLists.ToArray());

            combinedResult.IsSuccess.ShouldBeTrue();
        }
        public void Combine_if_all_HttpResultWithError_are_ok_returns_ok_HttpResultWithError()
        {
            var resultsLists = new List <HttpResultWithError <string> >
            {
                HttpResultWithError.Ok <string>(),
                HttpResultWithError.Ok <string>(),
                HttpResultWithError.Ok <string>()
            };

            var combinedResult = HttpResult.Combine(resultsLists.ToArray());

            combinedResult.IsSuccess.ShouldBeTrue();
        }
Example #3
0
        public void Combine_returns_first_fail_result_if_at_least_one_result_is_a_fail()
        {
            var firstHttpState  = Test.CreateHttpStateA();
            var secondHttpState = Test.CreateHttpStateB();
            var firstFailure    = HttpResult.Fail(firstHttpState);
            var resultsLists    = new List <HttpResult>
            {
                HttpResult.Ok(),
                firstFailure,
                HttpResult.Ok(),
                HttpResult.Fail(secondHttpState)
            };

            var combinedResult = HttpResult.Combine(resultsLists.ToArray());

            combinedResult.IsFailure.ShouldBeTrue();
            combinedResult.HttpState.ShouldBe(firstFailure.HttpState);
        }
        public void Combine_returns_first_fail_result_if_at_least_one_result_is_a_fail()
        {
            var httpState1 = Test.CreateHttpStateA();
            var httpState2 = Test.CreateHttpStateB();

            var firstFailure = HttpResult.Fail <string>(httpState1);
            var resultsLists = new List <HttpResult <string> >
            {
                HttpResult.Ok("value"),
                firstFailure,
                HttpResult.Ok("value"),
                HttpResult.Fail <string>(httpState2)
            };

            var combinedResult = HttpResult.Combine(resultsLists.ToArray());

            combinedResult.IsFailure.ShouldBeTrue();
            combinedResult.HttpState.ShouldBe(firstFailure.HttpState);
        }
        public void Combine_returns_first_fail_HttpResultWithValueAndError_if_at_least_one_HttpResultWithValueAndError_is_a_fail()
        {
            var firstHttpState  = Test.CreateHttpStateA();
            var secondHttpState = Test.CreateHttpStateB();

            var firstFailure = HttpResult.Fail <int, string>("error", firstHttpState);
            var resultsLists = new List <HttpResult <int, string> >
            {
                HttpResult.Ok <int, string>(1),
                firstFailure,
                HttpResult.Ok <int, string>(2),
                HttpResult.Fail <int, string>("secod error", secondHttpState)
            };

            var combinedResult = HttpResult.Combine(resultsLists.ToArray());

            combinedResult.IsFailure.ShouldBeTrue();
            combinedResult.Error.ShouldBe(firstFailure.Error);
            combinedResult.HttpState.ShouldBe(firstFailure.HttpState);
        }