I have some unit tests that test the post in a WebApi project it was a WebApi 1.0 version, that I have upgraded to webapi 2.0, now when trying to construct the response, and add the location of the new resource the ApiController.Url returns null. Prior to upgrading these unit tests were passing. Here is the setup of the controller
var config = new HttpConfiguration();
SetDependencyResolver(config, type);
var request = new HttpRequestMessage(method, url);
var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
var routeData =
new HttpRouteData(
route,
new HttpRouteValueDictionary { { "controller", controllerName } });
request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
controller.Configuration = config;
controller.ControllerContext = new HttpControllerContext(config, routeData, request);
controller.Request = request;
Here is the call that is failing . Note it is the Url object that is returning null
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = claimsCommand.Id }));
So what am I doing wrong now that I have upgrade to the latest version?