@@ -302,10 +302,19 @@ public void AddsMultipleParameters()
302302 Assert . Equal ( BindingSource . Body , fromBodyParam . Source ) ;
303303 }
304304
305+ [ Fact ]
306+ public void AddsDisplayNameFromRouteEndpoint ( )
307+ {
308+ var apiDescription = GetApiDescription ( ( ) => "foo" , displayName : "FOO" ) ;
309+
310+ Assert . Equal ( "FOO" , apiDescription . ActionDescriptor . DisplayName ) ;
311+ }
312+
305313 private IList < ApiDescription > GetApiDescriptions (
306314 Delegate action ,
307315 string pattern = null ,
308- IEnumerable < string > httpMethods = null )
316+ IEnumerable < string > httpMethods = null ,
317+ string displayName = null )
309318 {
310319 var methodInfo = action . Method ;
311320 var attributes = methodInfo . GetCustomAttributes ( ) ;
@@ -316,7 +325,7 @@ private IList<ApiDescription> GetApiDescriptions(
316325 var endpointMetadata = new EndpointMetadataCollection ( metadataItems . ToArray ( ) ) ;
317326 var routePattern = RoutePatternFactory . Parse ( pattern ?? "/" ) ;
318327
319- var endpoint = new RouteEndpoint ( httpContext => Task . CompletedTask , routePattern , 0 , endpointMetadata , null ) ;
328+ var endpoint = new RouteEndpoint ( httpContext => Task . CompletedTask , routePattern , 0 , endpointMetadata , displayName ) ;
320329 var endpointDataSource = new DefaultEndpointDataSource ( endpoint ) ;
321330 var hostEnvironment = new HostEnvironment
322331 {
@@ -331,8 +340,8 @@ private IList<ApiDescription> GetApiDescriptions(
331340 return context . Results ;
332341 }
333342
334- private ApiDescription GetApiDescription ( Delegate action , string pattern = null ) =>
335- Assert . Single ( GetApiDescriptions ( action , pattern ) ) ;
343+ private ApiDescription GetApiDescription ( Delegate action , string pattern = null , string displayName = null ) =>
344+ Assert . Single ( GetApiDescriptions ( action , pattern , displayName : displayName ) ) ;
336345
337346 private static void TestAction ( )
338347 {
0 commit comments