File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ public static IEnumerable<object[]> ActionDescriptorProviderContexts
114114 } ,
115115 new ControllerActionDescriptor ( )
116116 {
117- ControllerName = "Values2 " ,
117+ ControllerName = "Values " ,
118118 RouteValues = new Dictionary < string , string > ( )
119119 {
120120 [ "action" ] = "Get" ,
@@ -126,7 +126,7 @@ public static IEnumerable<object[]> ActionDescriptorProviderContexts
126126 } ,
127127 new ControllerActionDescriptor ( )
128128 {
129- ControllerName = "Values3 " ,
129+ ControllerName = "Values " ,
130130 RouteValues = new Dictionary < string , string > ( )
131131 {
132132 [ "action" ] = "Get" ,
Original file line number Diff line number Diff line change @@ -184,5 +184,30 @@ public void on_providers_executed_should_only_apply_api_version_model_convention
184184 } ) ;
185185 uiController . Actions . Single ( ) . GetProperty < ApiVersionModel > ( ) . Should ( ) . BeNull ( ) ;
186186 }
187+
188+ [ Theory ]
189+ [ InlineData ( "" ) ]
190+ [ InlineData ( "1" ) ]
191+ [ InlineData ( "42" ) ]
192+ public void on_providers_executed_should_trim_trailing_numbers_by_convention ( string suffix )
193+ {
194+ // arrange
195+ var controllerType = typeof ( object ) . GetTypeInfo ( ) ;
196+ var attributes = new object [ ] { new ApiControllerAttribute ( ) } ;
197+ var controller = new ControllerModel ( controllerType , attributes ) { ControllerName = "Values" + suffix } ;
198+ var controllerTypes = new [ ] { controller . ControllerType } ;
199+ var options = Options . Create ( new ApiVersioningOptions ( ) ) ;
200+ var filter = new DefaultApiControllerFilter ( new IApiControllerSpecification [ ] { new ApiBehaviorSpecification ( ) } ) ;
201+ var context = new ApplicationModelProviderContext ( controllerTypes ) ;
202+ var provider = new ApiVersioningApplicationModelProvider ( options , filter ) ;
203+
204+ context . Result . Controllers . Add ( controller ) ;
205+
206+ // act
207+ provider . OnProvidersExecuted ( context ) ;
208+
209+ // assert
210+ controller . ControllerName . Should ( ) . Be ( "Values" ) ;
211+ }
187212 }
188213}
You can’t perform that action at this time.
0 commit comments