public void ReturnExpectedActionResult(string result, TestClass1 payload, string message, Type expectedActionResultType)
        {
            var serRes = new ServiceResponse <TestClass1>
            {
                Result  = result,
                Payload = payload,
                Message = message
            };
            var r = ServiceResponseExtensions.ToActionResult(serRes, typeof(TestClass2), "default");

            r.ShouldBeOfType(expectedActionResultType);
        }
        static async Task <T> ReadAsync <T>(
            T serviceResponse,
            HttpResponseMessage responseMessage)
            where T : IHttpServiceResponse
        {
            serviceResponse = HttpServiceResponseExtensions.WithStatusCode(serviceResponse, responseMessage.StatusCode);

            if (responseMessage.IsSuccessStatusCode)
            {
                return(serviceResponse);
            }

            var errors = await responseMessage.Content
                         .ReadAsAsync <IEnumerable <string> >();

            return(ServiceResponseExtensions.WithErrors(serviceResponse, errors));
        }
        public void Maps_OkObjectResult()
        {
            string id = "1", msg = "msg";
            var    serRes = new ServiceResponse <TestClass1>
            {
                Result  = ServiceResult.Ok,
                Payload = new TestClass1 {
                    Id = int.Parse(id)
                },
                Message = msg
            };
            var r  = ServiceResponseExtensions.ToActionResult(serRes, typeof(TestClass2), "default");
            var ok = r.ShouldBeOfType <OkObjectResult>();

            ok.Value.GetPropertyValueByName <string>("message").ShouldBe(msg);
            var tc = ok.Value.GetPropertyValueByName <TestClass2>("data");

            tc.Id.ShouldBe(id);
        }