I have a WebApi project that I am trying to test. I have a controller -
public class UserController : ApiController
{
public string Get()
{
return "foo";
}
}
I need to test the route and I am trying to use WebApiContrib.Testing package.
Now, my problem is that while registering routes, I use GlobalConfiguration.Configuration.Routes
which is of type HttpRouteCollection
.
In my test, I can access RouteTable.Routes
but this is of type RouteCollection
.
As a result, I can't register the WebApi routes in my test, because of this type incompatibility.
Has anyone encountered this issue before? Is there something obvious that I am missing?
I resolved this by using:
WebApiConfig.Register( GlobalConfiguration.Configuration );
In TestFixtureSetup