@@ -92,21 +92,50 @@ public void match_should_be_true_when_api_version_is_requested_in_query_string(
9292 }
9393
9494 [ Theory ]
95- [ InlineData ( "http://localhost" , null ) ]
96- [ InlineData ( "http://localhost/$metadata" , "$metadata" ) ]
97- public void match_should_return_true_for_service_and_metadata_document ( string requestUri , string odataPath )
95+ [ InlineData ( "http://localhost" , null , "1.0" , true ) ]
96+ [ InlineData ( "http://localhost" , null , "2.0" , false ) ]
97+ [ InlineData ( "http://localhost/$metadata" , "$metadata" , "1.0" , true ) ]
98+ [ InlineData ( "http://localhost/$metadata" , "$metadata" , "2.0" , false ) ]
99+ public void match_should_return_expected_result_for_service_and_metadata_document ( string requestUri , string odataPath , string apiVersionValue , bool expected )
98100 {
99101 // arrange
102+ var apiVersion = Parse ( apiVersionValue ) ;
100103 var model = EmptyModel ;
101104 var request = new HttpRequestMessage ( Get , requestUri ) ;
102105 var values = new Dictionary < string , object > ( ) { { "odataPath" , odataPath } } ;
103- var constraint = NewVersionedODataPathRouteConstraint ( request , model , Default ) ;
106+ var constraint = NewVersionedODataPathRouteConstraint ( request , model , apiVersion ) ;
104107
105108 // act
106109 var result = constraint . Match ( request , null , null , values , UriResolution ) ;
107110
108111 // assert
109- result . Should ( ) . BeTrue ( ) ;
112+ result . Should ( ) . Be ( expected ) ;
113+ }
114+
115+ [ Theory ]
116+ [ InlineData ( true , true ) ]
117+ [ InlineData ( false , false ) ]
118+ public void match_should_return_expected_result_when_controller_is_implicitly_versioned ( bool allowImplicitVersioning , bool expected )
119+ {
120+ // arrange
121+ var apiVersion = new ApiVersion ( 2 , 0 ) ;
122+ var model = TestModel ;
123+ var request = new HttpRequestMessage ( Get , $ "http://localhost/Tests(1)" ) ;
124+ var values = new Dictionary < string , object > ( ) { { "odataPath" , "Tests(1)" } } ;
125+ var constraint = NewVersionedODataPathRouteConstraint ( request , model , apiVersion ) ;
126+
127+ request . GetConfiguration ( ) . AddApiVersioning (
128+ o =>
129+ {
130+ o . DefaultApiVersion = apiVersion ;
131+ o . AssumeDefaultVersionWhenUnspecified = allowImplicitVersioning ;
132+ } ) ;
133+
134+ // act
135+ var result = constraint . Match ( request , null , null , values , UriResolution ) ;
136+
137+ // assert
138+ result . Should ( ) . Be ( expected ) ;
110139 }
111140
112141 [ Theory ]
0 commit comments