ASP.NET 5/MVC 6 , API , , .
, ASP.NET vNext , , , , , . , area:exists.
[Fact]
public async Task RoutingToANonExistantArea_WithExistConstraint_RoutesToCorrectAction()
{
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient();
var response = await client.GetAsync("http://localhost/area-exists/Users");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var returnValue = await response.Content.ReadAsStringAsync();
Assert.Equal("Users.Index", returnValue);
}
[Fact]
public async Task RoutingToANonExistantArea_WithoutExistConstraint_RoutesToIncorrectAction()
{
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient();
var response = await client.GetAsync("http://localhost/area-withoutexists/Users");
var exception = response.GetServerException();
Assert.Equal("The view 'Index' was not found." +
" The following locations were searched:__/Areas/Users/Views/Home/Index.cshtml__" +
"/Areas/Users/Views/Shared/Index.cshtml__/Views/Shared/Index.cshtml.",
exception.ExceptionMessage);
}