Add functional tests for RazorPage routes

This commit is contained in:
Ryan Brandenburg 2017-03-15 15:43:55 -07:00
parent bc05f005ec
commit e5ccac8bf6
2 changed files with 41 additions and 2 deletions

View File

@ -93,7 +93,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
Assert.Equal("CustomActionResult", content);
}
[Fact]
public async Task PageModel_Handler_FormAction()
{
@ -167,6 +166,35 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
Assert.Equal("CustomActionResult", content);
}
[Fact]
public async Task RouteData_StringValueOnIntProp_ExpectsNotFound()
{
// Arrange
var routeRequest = new HttpRequestMessage(HttpMethod.Get, "http://localhost/RouteData/pizza");
// Act
var routeResponse = await Client.SendAsync(routeRequest);
// Assert
Assert.Equal(HttpStatusCode.NotFound, routeResponse.StatusCode);
}
[Fact]
public async Task RouteData_IntProperty_IsCoerced()
{
// Arrange
var routeRequest = new HttpRequestMessage(HttpMethod.Get, "http://localhost/RouteData/5");
// Act
var routeResponse = await Client.SendAsync(routeRequest);
// Assert
Assert.Equal(HttpStatusCode.OK, routeResponse.StatusCode);
var content = await routeResponse.Content.ReadAsStringAsync();
Assert.Equal("From RouteData: 5", content.Trim());
}
[Fact]
public async Task Page_SetsPath()
{
@ -415,7 +443,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
Assert.Equal("Login Page", content);
}
[Fact]
public async Task PageStart_IsDiscoveredWhenRootDirectoryIsNotSpecified()
{

View File

@ -0,0 +1,12 @@
@page "{intRouteDataStringProperty:int}"
@functions{
public string IntRouteDataStringProperty { get; set; }
public void OnGet(string intRouteDataStringProperty = "default")
{
IntRouteDataStringProperty = intRouteDataStringProperty;
}
}
From RouteData: @IntRouteDataStringProperty