I have a webapi controller that I am trying to unit test. However I am struggling to resolve the different types of ControllerContext. Most of the code examples I see are to do with testing MVC controllers and not Web API controllers.
The controller is defined as:
public class OrdersController : ApiController
{
I have this code which works when I run the application
uri = Url.Route("DefaultRoute", new { httproute = true, Id = order.Id});
However when I try to run it as a unit test, it fails. I have debugged it and find that Url is null when running unit tests, whereas if I run the system normally Url is an object of type System.Web.Http.Routing.UrlHelper.
Any idea how I can get Url.Route() to work when running unit tests?