public async Task PostReturnsPatient() { // Arrange. var config = new HttpConfiguration(); config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/Patients"); var route = config.Routes.MapHttpRoute("GetPatient", "api/{controller}/{id}"); var routeData = new HttpRouteData(route, new HttpRouteValueDictionary(new { controller = "Patients" })); var controller = new PatientsController { ControllerContext = new HttpControllerContext(config, routeData, request), Request = request, Url = new UrlHelper(request) }; controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; controller.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData; //Act. HttpResponseMessage response = await controller.CreatePatient(m_patient); //Assert. Patient patient = await response.Content.ReadAsAsync <Patient>(); Assert.IsTrue(response.StatusCode.Equals(HttpStatusCode.Created)); }