Fix routing tests (#8718)
This commit is contained in:
parent
8308d94e39
commit
5ed7658bf2
|
|
@ -142,12 +142,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
string template)
|
string template)
|
||||||
{
|
{
|
||||||
var endpoints = GetDefaultEndpoints();
|
var endpoints = GetDefaultEndpoints();
|
||||||
endpoints.Add(new RouteEndpoint(
|
endpoints.Add(CreateEndpoint(template, routeName: routeName));
|
||||||
httpContext => Task.CompletedTask,
|
|
||||||
RoutePatternFactory.Parse(template),
|
|
||||||
0,
|
|
||||||
EndpointMetadataCollection.Empty,
|
|
||||||
null));
|
|
||||||
return CreateUrlHelper(endpoints, appRoot, host, protocol);
|
return CreateUrlHelper(endpoints, appRoot, host, protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -181,7 +176,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
string template,
|
string template,
|
||||||
object defaults)
|
object defaults)
|
||||||
{
|
{
|
||||||
var endpoint = GetEndpoint(routeName, template, new RouteValueDictionary(defaults));
|
var endpoint = CreateEndpoint(template, new RouteValueDictionary(defaults), routeName: routeName);
|
||||||
var services = CreateServices(new[] { endpoint });
|
var services = CreateServices(new[] { endpoint });
|
||||||
var httpContext = CreateHttpContext(services, appRoot: "", host: null, protocol: null);
|
var httpContext = CreateHttpContext(services, appRoot: "", host: null, protocol: null);
|
||||||
var actionContext = CreateActionContext(httpContext);
|
var actionContext = CreateActionContext(httpContext);
|
||||||
|
|
@ -262,13 +257,6 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
requiredValues: new { controller = "home", action = "contact" },
|
requiredValues: new { controller = "home", action = "contact" },
|
||||||
order: 8,
|
order: 8,
|
||||||
routeName: "namedroute"));
|
routeName: "namedroute"));
|
||||||
endpoints.Add(
|
|
||||||
CreateEndpoint(
|
|
||||||
"any/url",
|
|
||||||
defaults: new { },
|
|
||||||
requiredValues: new { },
|
|
||||||
order: 9,
|
|
||||||
routeName: "MyRouteName"));
|
|
||||||
endpoints.Add(
|
endpoints.Add(
|
||||||
CreateEndpoint(
|
CreateEndpoint(
|
||||||
"api/orders/{id}",
|
"api/orders/{id}",
|
||||||
|
|
@ -315,15 +303,5 @@ namespace Microsoft.AspNetCore.Mvc.Routing
|
||||||
services.TryAddSingleton<IUrlHelperFactory, UrlHelperFactory>();
|
services.TryAddSingleton<IUrlHelperFactory, UrlHelperFactory>();
|
||||||
return services.BuildServiceProvider();
|
return services.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
private RouteEndpoint GetEndpoint(string name, string template, RouteValueDictionary defaults)
|
|
||||||
{
|
|
||||||
return new RouteEndpoint(
|
|
||||||
c => Task.CompletedTask,
|
|
||||||
RoutePatternFactory.Parse(template, defaults, parameterPolicies: null),
|
|
||||||
0,
|
|
||||||
EndpointMetadataCollection.Empty,
|
|
||||||
null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue