public void Should_set_properties_when_creating_non_xml_response_exception() { var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body"); var innerException = new Exception(); var result = new UnrecognisedErrorException(innerException, dummyResponse); Assert.That(result.ResponseBody, Is.EqualTo(dummyResponse.Body)); Assert.That(result.StatusCode, Is.EqualTo(dummyResponse.StatusCode)); }
public void Should_set_properties_when_creating_unrecognised_error_exception() { var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body"); var innerException = new Exception(); var result = new UnrecognisedErrorException(innerException, dummyResponse); Assert.That(result.ResponseBody, Is.EqualTo(dummyResponse.Body)); Assert.That(result.StatusCode, Is.EqualTo(dummyResponse.StatusCode)); Assert.That(result.Message, Is.EqualTo(UnrecognisedErrorException.DEFAULT_ERROR_MESSAGE)); Assert.That(result.InnerException, Is.SameAs(innerException)); }
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)); }