@@ -237,7 +237,7 @@ public void no_caching_if_user_authenticated_and_flag_set_to_off()
237237 public void etag_match_304_if_none_match ( )
238238 {
239239 _cache . Setup ( x => x . Contains ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) ) ) ) . Returns ( true ) ;
240- _cache . Setup ( x => x . Get ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) && i . Contains ( Constants . EtagKey ) ) ) )
240+ _cache . Setup ( x => x . Get < string > ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) && i . Contains ( Constants . EtagKey ) ) ) )
241241 . Returns ( @"""abc""" ) ;
242242
243243 var client = new HttpClient ( _server ) ;
@@ -254,8 +254,9 @@ public void etag_match_304_if_none_match()
254254 public void etag_not_match_304_if_none_match ( )
255255 {
256256 _cache . Setup ( x => x . Contains ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) ) ) ) . Returns ( true ) ;
257- _cache . Setup ( x => x . Get ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) && i . Contains ( Constants . EtagKey ) ) ) )
258- . Returns ( ( object ) new EntityTagHeaderValue ( @"""abcdef""" ) ) ;
257+ _cache . Setup ( x => x . Get < byte [ ] > ( It . IsAny < string > ( ) ) ) . Returns ( ( byte [ ] ) null ) ;
258+ _cache . Setup ( x => x . Get < string > ( It . Is < string > ( i => i . Contains ( "etag_match_304" ) && i . Contains ( Constants . EtagKey ) ) ) )
259+ . Returns ( @"""abcdef""" ) ;
259260
260261 var client = new HttpClient ( _server ) ;
261262 var req = new HttpRequestMessage ( HttpMethod . Get , _url + "etag_match_304" ) ;
@@ -267,6 +268,30 @@ public void etag_not_match_304_if_none_match()
267268 Assert . AreEqual ( HttpStatusCode . OK , result . StatusCode ) ;
268269 }
269270
271+ [ Test ]
272+ public void can_handle_ihttpactionresult_with_default_media_type ( )
273+ {
274+ var client = new HttpClient ( _server ) ;
275+ var result = client . GetAsync ( _url + "Get_ihttpactionresult" ) . Result ;
276+
277+ _cache . Verify ( s => s . Contains ( It . Is < string > ( x => x == "sample-get_ihttpactionresult:application/json; charset=utf-8" ) ) , Times . Exactly ( 2 ) ) ;
278+ _cache . Verify ( s => s . Add ( It . Is < string > ( x => x == "sample-get_ihttpactionresult" ) , It . IsAny < object > ( ) , It . Is < DateTimeOffset > ( x => x <= DateTime . Now . AddSeconds ( 100 ) ) , null ) , Times . Once ( ) ) ;
279+ _cache . Verify ( s => s . Add ( It . Is < string > ( x => x == "sample-get_ihttpactionresult:application/json; charset=utf-8" ) , It . IsAny < object > ( ) , It . Is < DateTimeOffset > ( x => x <= DateTime . Now . AddSeconds ( 100 ) ) , It . Is < string > ( x => x == "sample-get_ihttpactionresult" ) ) , Times . Once ( ) ) ;
280+ }
281+
282+ [ Test ]
283+ public void can_handle_ihttpactionresult_with_non_default_media_type ( )
284+ {
285+ var client = new HttpClient ( _server ) ;
286+ var req = new HttpRequestMessage ( HttpMethod . Get , _url + "Get_ihttpactionresult" ) ;
287+ req . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( "text/xml" ) ) ;
288+ var result = client . SendAsync ( req ) . Result ;
289+
290+ _cache . Verify ( s => s . Contains ( It . Is < string > ( x => x == "sample-get_ihttpactionresult:text/xml; charset=utf-8" ) ) , Times . Exactly ( 2 ) ) ;
291+ _cache . Verify ( s => s . Add ( It . Is < string > ( x => x == "sample-get_ihttpactionresult" ) , It . IsAny < object > ( ) , It . Is < DateTimeOffset > ( x => x <= DateTime . Now . AddSeconds ( 100 ) ) , null ) , Times . Once ( ) ) ;
292+ _cache . Verify ( s => s . Add ( It . Is < string > ( x => x == "sample-get_ihttpactionresult:text/xml; charset=utf-8" ) , It . IsAny < object > ( ) , It . Is < DateTimeOffset > ( x => x <= DateTime . Now . AddSeconds ( 100 ) ) , It . Is < string > ( x => x == "sample-get_ihttpactionresult" ) ) , Times . Once ( ) ) ;
293+ }
294+
270295
271296 //[Test]
272297 //public void must_add_querystring_to_cache_params()
0 commit comments