Having the following code:
return Request.CreateErrorResponse(
HttpStatusCode.BadRequest,
new ArgumentNullException("searchCriteria"));
I expect to be able to read ExceptionType back:
SearchCriteria searchCriteria = null;
HttpResponseMessage message = controller.Do(searchCriteria);
ObjectContent<HttpError> content = message.Content as ObjectContent<HttpError>;
HttpError error = (HttpError)content.Value;
string exceptionType = error.ExceptionType;
but the last line gives always `null`? Why is that?
Comments: Looks like we have a bug in how controller testability works. Setting RequestContext on the controller is order dependant with setting the request. It should really cache the data temporarily if there is no request set, but ultimately defer to the request if one is available.
return Request.CreateErrorResponse(
HttpStatusCode.BadRequest,
new ArgumentNullException("searchCriteria"));
I expect to be able to read ExceptionType back:
SearchCriteria searchCriteria = null;
HttpResponseMessage message = controller.Do(searchCriteria);
ObjectContent<HttpError> content = message.Content as ObjectContent<HttpError>;
HttpError error = (HttpError)content.Value;
string exceptionType = error.ExceptionType;
but the last line gives always `null`? Why is that?
Comments: Looks like we have a bug in how controller testability works. Setting RequestContext on the controller is order dependant with setting the request. It should really cache the data temporarily if there is no request set, but ultimately defer to the request if one is available.