ASP.Net MVC 4 RC의 ApiController를 사용하고 있으며 Get 메서드를 단위 테스트하려고합니다.HttpRequestMessage에서 CreateResponse <T> 확장 메서드를 모의하는 방법
이 메서드는 HttpRequestMessage에있는 CreateResponse 메서드를 사용하지만이 메서드를 조롱하거나 제대로 작동시키는 방법을 모릅니다. 내 단위 테스트 내
MediaTypeHeaderValue header = new MediaTypeHeaderValue(versionedSmartBlock.ContentType);
var response = Request.CreateResponse<SmartBlock>(HttpStatusCode.OK, versionedSmartBlock, header);
, 나는 빈 HttpRequestMessage 만들 :
는방법의 몸이 포함
CallsController api = new CallsController(managerMock.Object, config, adapterFactoryMock.Object);
api.Request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Initiate?ern=%2B44123456789");
var response = api.Get("+44123456789", null);
을하지만 그것은 단지 InvalidOperationException이 생성
요청은하지 않습니다 연관된 구성 오브젝트가 있거나 제공된 구성이 널 (null) 인 경우.
누군가가 HttpRequestMessage를 구성하여 어떻게 CreateResponse 메서드가 실제로 작업을 수행 할 수 있는지에 대한 지침을 얻었습니까?
같은 문제가 발생하는 것 같습니다. http://stackoverflow.com/questions/10868673/asp-net-webapi-unit-testing-with-request-createresponse –