You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 19, 2024. It is now read-only.
I have a Web project and a Test Project. I'm using webapi in the web project and MVCRoute tester in the second.
Test is
[TestFixture]
class TestApiRoute
{
HttpConfiguration config;
[SetUp]
public void Setup()
{
RouteAssert.UseAssertEngine(new NunitAssertEngine());
config = new HttpConfiguration();
WebApiConfig.Register(config);
config.EnsureInitialized();
}
[Test]
public void HasResourceApiRoute()
{
RouteAssert.HasApiRoute(config, "/api/resource", HttpMethod.Get);
}
}
WebAPIConfig
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
This test fails with Route with controller not found for url 'http://site.com/api/resource'
but if I run the project the route/controller work fine.
Obviously I done the setup incorrect, but I'm not sure where, and the documentation isn't very clear on how you should setup 'config'
I have a Web project and a Test Project. I'm using webapi in the web project and MVCRoute tester in the second.
Test is
WebAPIConfig
This test fails with
Route with controller not found for url 'http://site.com/api/resource'but if I run the project the route/controller work fine.
Obviously I done the setup incorrect, but I'm not sure where, and the documentation isn't very clear on how you should setup 'config'