Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MapGroup link generation test #44562

Merged
merged 2 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Mvc/test/Mvc.FunctionalTests/RoutingGroupsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public async Task MatchesPagesGroupAndGeneratesValidLink()

var document = await response.GetHtmlDocumentAsync();
var editLink = document.RequiredQuerySelector("#editlink");
var contactLink = document.RequiredQuerySelector("#contactlink");
Assert.Equal("/pages/Edit/10", editLink.GetAttribute("href"));
// TODO: Investigate why the #contactlink to the controller is empty.
Assert.Equal("/controllers/contoso/Home/Contact", contactLink.GetAttribute("href"));
}

private record RouteInfo(string RouteName, IDictionary<string, string> RouteValues, string Link);
Expand Down
4 changes: 2 additions & 2 deletions src/Mvc/test/Mvc.FunctionalTests/RoutingTestsBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Net;
Expand Down Expand Up @@ -1554,7 +1554,7 @@ public async Task RazorPage_WithLinks_GeneratesLinksCorrectly()
Assert.Equal("/Edit/10", editLink.GetAttribute("href"));

var contactLink = document.RequiredQuerySelector("#contactlink");
Assert.Equal("/Home/Contact", contactLink.GetAttribute("href"));
Assert.Equal("/Home/Contact?org=contoso", contactLink.GetAttribute("href"));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

<a id="editlink" asp-page="/Edit" asp-route-id="10">Edit</a>
<br />
<a id="contactlink" asp-action="Contact" asp-controller="Home">Contact</a>
<a id="contactlink" asp-action="Contact" asp-controller="Home" asp-route-org="contoso">Contact</a>
2 changes: 1 addition & 1 deletion src/Mvc/test/WebSites/RoutingWebSite/StartupForGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public virtual void Configure(IApplicationBuilder app)
pagesGroup.MapRazorPages();

var controllerGroup = endpoints.MapGroup("/controllers/{org}");
controllerGroup.MapControllers();
controllerGroup.MapControllerRoute(name: "default", pattern: "{controller}/{action}/{id?}");
});
}
}