I have upgraded my web api project to the latest version, using MVC 5 The application runs properly but this line of code is not working anymore on my unit tests:
string uri = this.Url.Link("DefaultApi", new { id = savedOrganization.Id });
The Url property of the controller is now null. This is how I configure the mock controller:
var config = new HttpConfiguration();
var request = new HttpRequestMessage(HttpMethod.Post, "http://xxx/api/organization");
var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
var routeData = new HttpRouteData(route, new HttpRouteValueDictionary {{"controller", "organization"}});
controller.ControllerContext = new HttpControllerContext(config, routeData, request);
controller.Request = request;
controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
controller.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
Before upgrading to MVC 5 it was working fine.
When I debug the test it shows that the Url property is now null