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: Fixed the latest issue mentioned in the above comment. There is no order requirement anymore between setting controller.RequestContext and controller.Request. Note that for unit testing this is not true for setting them controller.ControllerContext.RequestContext and controller.ControllerContext.Request. The ControllerContext is not intended to be used by unit test 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: Fixed the latest issue mentioned in the above comment. There is no order requirement anymore between setting controller.RequestContext and controller.Request. Note that for unit testing this is not true for setting them controller.ControllerContext.RequestContext and controller.ControllerContext.Request. The ControllerContext is not intended to be used by unit test code.