* #4847 Fix MapAreaRoute override existing area constraint Modify Test project Modify web test routing * wrong field tested * IntRouteConstraint expected * Default for area route on Travel area * Removed commented code simplify constraintsDictionary area assign renamed test method * test name * renamedd test to MapAreaRoute_DoesNotReplaceValuesForAreaIfAlreadyPresentInConstraintsOrDefaults
This commit is contained in:
parent
3d2bb673ee
commit
b4677a44da
|
|
@ -128,10 +128,10 @@ namespace Microsoft.AspNetCore.Builder
|
|||
}
|
||||
|
||||
var defaultsDictionary = new RouteValueDictionary(defaults);
|
||||
defaultsDictionary["area"] = areaName;
|
||||
defaultsDictionary["area"] = defaultsDictionary["area"] ?? areaName;
|
||||
|
||||
var constraintsDictionary = new RouteValueDictionary(constraints);
|
||||
constraintsDictionary["area"] = areaName;
|
||||
constraintsDictionary["area"] = constraintsDictionary["area"] ?? areaName;
|
||||
|
||||
routeBuilder.MapRoute(name, template, defaultsDictionary, constraintsDictionary, dataTokens);
|
||||
return routeBuilder;
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void MapAreaRoute_ReplacesValuesForArea()
|
||||
public void MapAreaRoute_DoesNotReplaceValuesForAreaIfAlreadyPresentInConstraintsOrDefaults()
|
||||
{
|
||||
// Arrange
|
||||
var builder = CreateRouteBuilder();
|
||||
|
|
@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
kvp =>
|
||||
{
|
||||
Assert.Equal(kvp.Key, "area");
|
||||
Assert.IsType<RegexRouteConstraint>(kvp.Value);
|
||||
Assert.IsType<IntRouteConstraint>(kvp.Value);
|
||||
});
|
||||
Assert.Collection(
|
||||
route.DataTokens.OrderBy(kvp => kvp.Key),
|
||||
|
|
@ -223,7 +223,7 @@ namespace Microsoft.AspNetCore.Builder
|
|||
kvp =>
|
||||
{
|
||||
Assert.Equal(kvp.Key, "area");
|
||||
Assert.Equal(kvp.Value, "admin");
|
||||
Assert.Equal(kvp.Value, "Home");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,13 @@ namespace RoutingWebSite
|
|||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
"areaRoute",
|
||||
"{area:exists}/{controller}/{action}",
|
||||
new { controller = "Home", action = "Index" });
|
||||
routes.MapAreaRoute(
|
||||
"flightRoute",
|
||||
"adminRoute",
|
||||
"{area:exists}/{controller}/{action}",
|
||||
new { controller = "Home", action = "Index" },
|
||||
new { area = "Travel" }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
"ActionAsMethod",
|
||||
|
|
|
|||
Loading…
Reference in New Issue