private static ApiWebException MakeOriginalException() { var innerException = new WebException("test"); var requestBody = new RequestPayload("foo", "bar"); var headers = new Dictionary<string, string> {{"key1", "value1"}}; var originalRequest = new Request(HttpMethod.Get, "http://foo.com/bar?foo=bar", headers, requestBody); var inputException = new ApiWebException("request failed", innerException, originalRequest); return inputException; }
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)); }