Skip to content

Commit

Permalink
Improve MapGroup link generation test (#44562)
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 authored Oct 18, 2022
1 parent 312706f commit 5e42cca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
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?}");
});
}
}

0 comments on commit 5e42cca

Please sign in to comment.