Skip to content

Commit 5e42cca

Browse files
authored
Improve MapGroup link generation test (#44562)
1 parent 312706f commit 5e42cca

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/Mvc/test/Mvc.FunctionalTests/RoutingGroupsTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public async Task MatchesPagesGroupAndGeneratesValidLink()
4646

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

5354
private record RouteInfo(string RouteName, IDictionary<string, string> RouteValues, string Link);

src/Mvc/test/Mvc.FunctionalTests/RoutingTestsBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

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

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

15601560
[Fact]

src/Mvc/test/WebSites/RoutingWebSite/Pages/PageWithLinks.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
<a id="editlink" asp-page="/Edit" asp-route-id="10">Edit</a>
77
<br />
8-
<a id="contactlink" asp-action="Contact" asp-controller="Home">Contact</a>
8+
<a id="contactlink" asp-action="Contact" asp-controller="Home" asp-route-org="contoso">Contact</a>

src/Mvc/test/WebSites/RoutingWebSite/StartupForGroups.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public virtual void Configure(IApplicationBuilder app)
2929
pagesGroup.MapRazorPages();
3030

3131
var controllerGroup = endpoints.MapGroup("/controllers/{org}");
32-
controllerGroup.MapControllers();
32+
controllerGroup.MapControllerRoute(name: "default", pattern: "{controller}/{action}/{id?}");
3333
});
3434
}
3535
}

0 commit comments

Comments
 (0)