Test basic link generation in Razor pages in both regular and endpoint routing
This commit is contained in:
parent
f9c309dd71
commit
4d98ea801e
|
|
@ -1241,6 +1241,24 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
Assert.Equal(actionName, result.Action);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RazorPage_WithLinks_GeneratesLinksCorrectly()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost/PageWithLinks");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
|
||||
var document = await response.GetHtmlDocumentAsync();
|
||||
|
||||
var editLink = document.RequiredQuerySelector("#editlink");
|
||||
Assert.Equal("/Edit/10", editLink.GetAttribute("href"));
|
||||
|
||||
var contactLink = document.RequiredQuerySelector("#contactlink");
|
||||
Assert.Equal("/Home/Contact", contactLink.GetAttribute("href"));
|
||||
}
|
||||
|
||||
protected static LinkBuilder LinkFrom(string url)
|
||||
{
|
||||
return new LinkBuilder(url);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
@page "{id}"
|
||||
|
||||
Hello from Edit page
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
@page
|
||||
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
|
||||
@{
|
||||
}
|
||||
|
||||
<a id="editlink" asp-page="/Edit" asp-route-id="10">Edit</a>
|
||||
<br />
|
||||
<a id="contactlink" asp-action="Contact" asp-controller="Home">Contact</a>
|
||||
Loading…
Reference in New Issue