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
114
114
} ,
115
115
new ControllerActionDescriptor ( )
116
116
{
117
- ControllerName = "Values2 " ,
117
+ ControllerName = "Values " ,
118
118
RouteValues = new Dictionary < string , string > ( )
119
119
{
120
120
[ "action" ] = "Get" ,
@@ -126,7 +126,7 @@ public static IEnumerable<object[]> ActionDescriptorProviderContexts
126
126
} ,
127
127
new ControllerActionDescriptor ( )
128
128
{
129
- ControllerName = "Values3 " ,
129
+ ControllerName = "Values " ,
130
130
RouteValues = new Dictionary < string , string > ( )
131
131
{
132
132
[ "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
184
184
} ) ;
185
185
uiController . Actions . Single ( ) . GetProperty < ApiVersionModel > ( ) . Should ( ) . BeNull ( ) ;
186
186
}
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
+ }
187
212
}
188
213
}
You can’t perform that action at this time.
0 commit comments