public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var inputException = new MissingDependencyException(typeof(string));

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }
        public void Should_round_trip_serialise_and_deserialise_exception_with_original_request()
        {
            var inputException = MakeOriginalException();

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            var inputRequest  = inputException.OriginalRequest;
            var outputRequest = outputException.OriginalRequest;

            Assert.That(outputRequest.Url, Is.EqualTo(inputRequest.Url));
            Assert.That(outputRequest.Method, Is.EqualTo(inputRequest.Method));
        }
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var innerException = new WebException("test");
            var inputException = new ApiWebException("request failed", innerException);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException, Is.Not.Null);
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
            Assert.That(outputException.InnerException, Is.InstanceOf <WebException>());
            Assert.That(outputException.InnerException.Message, Is.EqualTo(innerException.Message));
        }
        public void Should_round_trip_serialise_and_deserialise_exception_request_payload()
        {
            var inputException = MakeOriginalException();

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            var inputRequest  = inputException.OriginalRequest;
            var outputRequest = outputException.OriginalRequest;

            Assert.That(outputRequest.Body, Is.Not.Null);
            Assert.That(outputRequest.Body.ContentType, Is.EqualTo(inputRequest.Body.ContentType));
            Assert.That(outputRequest.Body.Data, Is.EqualTo(inputRequest.Body.Data));
        }
        public void Should_round_trip_serialise_and_deserialise_exception_request_headers()
        {
            var inputException = MakeOriginalException();

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            var inputRequest  = inputException.OriginalRequest;
            var outputRequest = outputException.OriginalRequest;

            Assert.That(outputRequest.Headers, Is.Not.Null);
            Assert.That(outputRequest.Headers.Count, Is.EqualTo(inputRequest.Headers.Count));
            Assert.That(outputRequest.Headers.Keys.First(), Is.EqualTo(inputRequest.Headers.Keys.First()));
            Assert.That(outputRequest.Headers.Values.First(), Is.EqualTo(inputRequest.Headers.Values.First()));
        }
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var headers = new Dictionary <string, string>
            {
                { "Header1", "Header1Value" },
                { "Header2", "Header2Value" }
            };
            var response       = new Response(HttpStatusCode.Conflict, headers, "responseBody");
            var inputException = new NonXmlResponseException(response);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.Headers, Is.EqualTo(inputException.Headers));
            Assert.That(outputException.ResponseBody, Is.EqualTo(inputException.ResponseBody));
            Assert.That(outputException.StatusCode, Is.EqualTo(inputException.StatusCode));
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var headers = new Dictionary <string, string>
            {
                { "Header1", "Header1Value" },
                { "Header2", "Header2Value" }
            };
            var response       = new Response(HttpStatusCode.Conflict, headers, "responseBody");
            var inputException = new RemoteApiException("The server had an error", response, ErrorCode.UnexpectedInternalServerError);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.ErrorCode, Is.EqualTo(inputException.ErrorCode));
            Assert.That(outputException.Headers, Is.EqualTo(inputException.Headers));
            Assert.That(outputException.ResponseBody, Is.EqualTo(inputException.ResponseBody));
            Assert.That(outputException.StatusCode, Is.EqualTo(inputException.StatusCode));
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }
Exemple #8
0
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var headers = new Dictionary <string, string>
            {
                { "Header1", "Header1Value" },
                { "Header2", "Header2Value" }
            };
            var response = new Response(HttpStatusCode.OK, headers, "responseBody");

            var inputException = new UserCardException("user card has expired", response, ErrorCode.UserCardHasExpired);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.Headers, Is.EqualTo(inputException.Headers));
            Assert.That(outputException.ResponseBody, Is.EqualTo(inputException.ResponseBody));
            Assert.That(outputException.StatusCode, Is.EqualTo(inputException.StatusCode));
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var headers = new Dictionary <string, string>
            {
                { "Header1", "Header1Value" },
                { "Header2", "Header2Value" }
            };
            var response       = new Response(HttpStatusCode.Conflict, headers, "responseBody");
            var inputException = new InputParameterException("The parameter value is bad", response, ErrorCode.InvalidParameterValue);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.ErrorCode, Is.EqualTo(inputException.ErrorCode));
            Assert.That(outputException.Headers, Is.EqualTo(inputException.Headers));
            Assert.That(outputException.ResponseBody, Is.EqualTo(inputException.ResponseBody));
            Assert.That(outputException.StatusCode, Is.EqualTo(inputException.StatusCode));
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }
Exemple #10
0
        public void Should_round_trip_serialise_and_deserialise_exception()
        {
            var headers = new Dictionary <string, string>
            {
                { "Header1", "Header1Value" },
                { "Header2", "Header2Value" }
            };
            var response       = new Response(HttpStatusCode.InternalServerError, headers, "responseBody");
            var innerException = new Exception();

            var inputException = new UnrecognisedErrorException(innerException, response);

            var roundTripSerialiser = new RoundTripSerialiser();
            var outputException     = roundTripSerialiser.RoundTrip(inputException);

            Assert.That(outputException.Headers, Is.EqualTo(inputException.Headers));
            Assert.That(outputException.ResponseBody, Is.EqualTo(inputException.ResponseBody));
            Assert.That(outputException.StatusCode, Is.EqualTo(inputException.StatusCode));
            Assert.That(outputException.Message, Is.EqualTo(inputException.Message));
        }