Add functional tests for RazorPage routes
This commit is contained in:
parent
bc05f005ec
commit
e5ccac8bf6
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
@page "{intRouteDataStringProperty:int}"
|
||||
|
||||
@functions{
|
||||
public string IntRouteDataStringProperty { get; set; }
|
||||
|
||||
public void OnGet(string intRouteDataStringProperty = "default")
|
||||
{
|
||||
IntRouteDataStringProperty = intRouteDataStringProperty;
|
||||
}
|
||||
}
|
||||
|
||||
From RouteData: @IntRouteDataStringProperty
|
||||
Loading…
Reference in New Issue