I've seen a lot of examples around doing ASP.NET (.NET Framework not .NET Core) MVC integration tests using a HttpServer
hosting an ApiController
, but it doesn't seem to be able to host/expose a normal Controller
.
For example, the following setup works:
Controller
public class TestController : ApiController
{
[HttpGet]
public string Debug()
{
return "This is debug content";
}
}
Test
var config = new HttpConfiguration();
config.Routes.MapHttpRoute("Default", "{controller}/{action}");
var server = new HttpServer(config);
var client = new HttpClient(server);
var response = await client.GetAsync("http://whatever/test/debug");
response.EnsureSuccessStatusCode();
If I change my TestController
to extend Controller
instead of ApiController
, the response becomes 404.
Am I missing something here or this has never been supported?