From 0dc13adfa03e4134260f209157cabc4d82b0851a Mon Sep 17 00:00:00 2001 From: Heiner Morales Date: Fri, 5 Jul 2019 16:18:41 -0600 Subject: [PATCH] Adding Suport to Slide Cache --- .../Cache/IApiOutputCache.cs | 2 +- .../Cache/MemoryCacheDefault.cs | 18 ++--- src/WebApi.OutputCache.Core/Time/CacheTime.cs | 2 + src/WebApi.OutputCache.Core/Time/ShortTime.cs | 12 ++- .../CacheOutputAttribute.cs | 25 +++--- .../CacheKeyGeneratorRegistrationTests.cs | 2 +- .../CacheKeyGeneratorTests.cs | 8 +- .../ConnegTests.cs | 4 +- .../MemoryCacheForTests.cs | 2 +- .../ServerSideTests.cs | 76 +++++++++---------- 10 files changed, 81 insertions(+), 70 deletions(-) diff --git a/src/WebApi.OutputCache.Core/Cache/IApiOutputCache.cs b/src/WebApi.OutputCache.Core/Cache/IApiOutputCache.cs index 9365d98..7edc9e6 100644 --- a/src/WebApi.OutputCache.Core/Cache/IApiOutputCache.cs +++ b/src/WebApi.OutputCache.Core/Cache/IApiOutputCache.cs @@ -16,7 +16,7 @@ public interface IApiOutputCache bool Contains(string key); - void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null); + void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null, TimeSpan slidingExpiration = default(TimeSpan), bool slide = false); IEnumerable AllKeys { get; } } diff --git a/src/WebApi.OutputCache.Core/Cache/MemoryCacheDefault.cs b/src/WebApi.OutputCache.Core/Cache/MemoryCacheDefault.cs index 157eaa0..178183e 100644 --- a/src/WebApi.OutputCache.Core/Cache/MemoryCacheDefault.cs +++ b/src/WebApi.OutputCache.Core/Cache/MemoryCacheDefault.cs @@ -42,18 +42,18 @@ public virtual bool Contains(string key) return Cache.Contains(key); } - public virtual void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null) + public virtual void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null, TimeSpan slidingExpiration = default(TimeSpan), bool slide = false) { - var cachePolicy = new CacheItemPolicy - { - AbsoluteExpiration = expiration - }; + var cachePolicy = new CacheItemPolicy(); + + if (slide) + cachePolicy.SlidingExpiration = slidingExpiration; + else + cachePolicy.AbsoluteExpiration = expiration; - if (!string.IsNullOrWhiteSpace(dependsOnKey)) + if (!string.IsNullOrWhiteSpace(dependsOnKey) && !slide) { - cachePolicy.ChangeMonitors.Add( - Cache.CreateCacheEntryChangeMonitor(new[] { dependsOnKey }) - ); + cachePolicy.ChangeMonitors.Add(Cache.CreateCacheEntryChangeMonitor(new[] { dependsOnKey })); } lock (Cache) { diff --git a/src/WebApi.OutputCache.Core/Time/CacheTime.cs b/src/WebApi.OutputCache.Core/Time/CacheTime.cs index 3138477..8563884 100644 --- a/src/WebApi.OutputCache.Core/Time/CacheTime.cs +++ b/src/WebApi.OutputCache.Core/Time/CacheTime.cs @@ -10,5 +10,7 @@ public class CacheTime public TimeSpan? SharedTimeSpan { get; set; } public DateTimeOffset AbsoluteExpiration { get; set; } + + public TimeSpan SlidingExpiration { get; set; } } } \ No newline at end of file diff --git a/src/WebApi.OutputCache.Core/Time/ShortTime.cs b/src/WebApi.OutputCache.Core/Time/ShortTime.cs index 0a91dd3..78a5ee4 100644 --- a/src/WebApi.OutputCache.Core/Time/ShortTime.cs +++ b/src/WebApi.OutputCache.Core/Time/ShortTime.cs @@ -7,8 +7,9 @@ public class ShortTime : IModelQuery private readonly int serverTimeInSeconds; private readonly int clientTimeInSeconds; private readonly int? sharedTimeInSecounds; + private readonly bool slideExpiration; - public ShortTime(int serverTimeInSeconds, int clientTimeInSeconds, int? sharedTimeInSecounds) + public ShortTime(int serverTimeInSeconds, int clientTimeInSeconds, int? sharedTimeInSeconds, bool slideExpiration) { if (serverTimeInSeconds < 0) serverTimeInSeconds = 0; @@ -20,10 +21,12 @@ public ShortTime(int serverTimeInSeconds, int clientTimeInSeconds, int? sharedTi this.clientTimeInSeconds = clientTimeInSeconds; - if (sharedTimeInSecounds.HasValue && sharedTimeInSecounds.Value < 0) - sharedTimeInSecounds = 0; + if (sharedTimeInSeconds.HasValue && sharedTimeInSeconds.Value < 0) + sharedTimeInSeconds = 0; - this.sharedTimeInSecounds = sharedTimeInSecounds; + this.sharedTimeInSecounds = sharedTimeInSeconds; + + this.slideExpiration = slideExpiration; } public CacheTime Execute(DateTime model) @@ -31,6 +34,7 @@ public CacheTime Execute(DateTime model) var cacheTime = new CacheTime { AbsoluteExpiration = model.AddSeconds(serverTimeInSeconds), + SlidingExpiration = TimeSpan.FromSeconds(serverTimeInSeconds), ClientTimeSpan = TimeSpan.FromSeconds(clientTimeInSeconds), SharedTimeSpan = sharedTimeInSecounds.HasValue ? (TimeSpan?) TimeSpan.FromSeconds(sharedTimeInSecounds.Value) : null }; diff --git a/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs b/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs index fc79e71..ce15183 100644 --- a/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs +++ b/src/WebApi.OutputCache.V2/CacheOutputAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; @@ -16,6 +15,7 @@ using WebApi.OutputCache.Core; using WebApi.OutputCache.Core.Cache; using WebApi.OutputCache.Core.Time; +using System.Collections.Generic; namespace WebApi.OutputCache.V2 { @@ -50,7 +50,6 @@ public class CacheOutputAttribute : ActionFilterAttribute /// public int ClientTimeSpan { get; set; } - private int? _sharedTimeSpan = null; /// @@ -77,6 +76,11 @@ public int SharedTimeSpan /// public bool Private { get; set; } + /// + /// Sets cache expiration to from absolute to sliding. When cache expiration is set to sliding, the Cache-Control HTTP header will be renewed with each response. + /// + public bool Slide { get; set; } + /// /// Class used to generate caching keys /// @@ -127,7 +131,7 @@ protected virtual void EnsureCacheTimeQuery() protected void ResetCacheTimeQuery() { - CacheTimeQuery = new ShortTime( ServerTimeSpan, ClientTimeSpan, _sharedTimeSpan); + CacheTimeQuery = new ShortTime(ServerTimeSpan, ClientTimeSpan, _sharedTimeSpan, Slide); } protected virtual MediaTypeHeaderValue GetExpectedMediaType(HttpConfiguration config, HttpActionContext actionContext) @@ -238,7 +242,7 @@ public override void OnActionExecuting(HttpActionContext actionContext) if (responseHeaders != null) AddCustomCachedHeaders(actionContext.Response, responseHeaders, responseContentHeaders); var cacheTime = CacheTimeQuery.Execute(DateTime.Now); - ApplyCacheHeaders(actionContext.Response, cacheTime, contentGenerationTimestamp); + ApplyCacheHeaders(actionContext.Response, cacheTime, Slide ? DateTimeOffset.Now : contentGenerationTimestamp); } public override async Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) @@ -249,7 +253,7 @@ public override async Task OnActionExecutedAsync(HttpActionExecutedContext actio var actionExecutionTimestamp = DateTimeOffset.Now; var cacheTime = CacheTimeQuery.Execute(actionExecutionTimestamp.DateTime); - if (cacheTime.AbsoluteExpiration > actionExecutionTimestamp) + if (cacheTime.AbsoluteExpiration > actionExecutionTimestamp || Slide) { var httpConfig = actionExecutedContext.Request.GetConfiguration(); var config = httpConfig.CacheOutputConfiguration(); @@ -274,22 +278,23 @@ public override async Task OnActionExecutedAsync(HttpActionExecutedContext actio responseContent.Headers.Remove("Content-Length"); - _webApiCache.Add(baseKey, string.Empty, cacheTime.AbsoluteExpiration); - _webApiCache.Add(cachekey, content, cacheTime.AbsoluteExpiration, baseKey); + _webApiCache.Add(baseKey, string.Empty, cacheTime.AbsoluteExpiration, null, cacheTime.SlidingExpiration, Slide); + _webApiCache.Add(cachekey, content, cacheTime.AbsoluteExpiration, baseKey, cacheTime.SlidingExpiration, Slide); _webApiCache.Add(cachekey + Constants.ContentTypeKey, contentType, - cacheTime.AbsoluteExpiration, baseKey); + cacheTime.AbsoluteExpiration, baseKey, cacheTime.SlidingExpiration, Slide); _webApiCache.Add(cachekey + Constants.EtagKey, etag, - cacheTime.AbsoluteExpiration, baseKey); + cacheTime.AbsoluteExpiration, baseKey, cacheTime.SlidingExpiration, Slide); + _webApiCache.Add(cachekey + Constants.GenerationTimestampKey, actionExecutionTimestamp.ToString(), - cacheTime.AbsoluteExpiration, baseKey); + cacheTime.AbsoluteExpiration, baseKey, cacheTime.SlidingExpiration, Slide); if (!String.IsNullOrEmpty(IncludeCustomHeaders)) { diff --git a/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorRegistrationTests.cs b/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorRegistrationTests.cs index 46d2ae9..4bca02d 100644 --- a/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorRegistrationTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorRegistrationTests.cs @@ -89,7 +89,7 @@ public void selected_generator_with_internal_registration_is_used() var client = new HttpClient(_server); var result = client.GetAsync(_url + "cachekey/get_internalregistered").Result; - _cache.Verify(s => s.Add(It.Is(x => x == "internal"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_internalregistered")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "internal"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_internalregistered"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] diff --git a/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorTests.cs b/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorTests.cs index ffdfcab..4b9302b 100644 --- a/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/CacheKeyGeneratorTests.cs @@ -66,8 +66,8 @@ public void custom_default_cache_key_generator_called_and_key_used() var result = client.GetAsync(_url + "sample/Get_c100_s100").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "keykeykey")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "keykeykey"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "keykeykey:response-ct"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "keykeykey"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "keykeykey:response-ct"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); _keyGeneratorA.VerifyAll(); } @@ -79,8 +79,8 @@ public void custom_cache_key_generator_called() var result = client.GetAsync(_url + "cachekey/get_custom_key").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "custom_key")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "custom_key"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_custom_key")), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "custom_key:response-ct"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_custom_key")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "custom_key"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_custom_key"), It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "custom_key:response-ct"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.cachekeycontroller-get_custom_key"), It.IsAny(), It.IsAny()), Times.Once()); } } } diff --git a/test/WebApi.OutputCache.V2.Tests/ConnegTests.cs b/test/WebApi.OutputCache.V2.Tests/ConnegTests.cs index 2457dfe..988647c 100644 --- a/test/WebApi.OutputCache.V2.Tests/ConnegTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/ConnegTests.cs @@ -43,14 +43,14 @@ public void subsequent_xml_request_is_not_cached() var result = client.GetAsync(_url + "Get_c100_s100").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x < DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x < DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); var req = new HttpRequestMessage(HttpMethod.Get, _url + "Get_c100_s100"); req.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml")); var result2 = client.SendAsync(req).Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x < DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x < DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); } diff --git a/test/WebApi.OutputCache.V2.Tests/MemoryCacheForTests.cs b/test/WebApi.OutputCache.V2.Tests/MemoryCacheForTests.cs index bd7431e..d1f656f 100644 --- a/test/WebApi.OutputCache.V2.Tests/MemoryCacheForTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/MemoryCacheForTests.cs @@ -42,7 +42,7 @@ public virtual bool Contains(string key) return _cachedItems.ContainsKey(key); } - public virtual void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null) + public virtual void Add(string key, object o, DateTimeOffset expiration, string dependsOnKey = null, TimeSpan slidingExpiration = default(TimeSpan), bool slide = false) { _cachedItems.Add(key, o); } diff --git a/test/WebApi.OutputCache.V2.Tests/ServerSideTests.cs b/test/WebApi.OutputCache.V2.Tests/ServerSideTests.cs index 27912e7..2453c79 100644 --- a/test/WebApi.OutputCache.V2.Tests/ServerSideTests.cs +++ b/test/WebApi.OutputCache.V2.Tests/ServerSideTests.cs @@ -49,8 +49,8 @@ public void set_cache_to_predefined_value() var result = client.GetAsync(_url + "Get_c100_s100").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -62,8 +62,8 @@ public void set_cache_to_predefined_value_c100_s0() // NOTE: Should we expect the _cache to not be called at all if the ServerTimeSpan is 0? _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0:application/json; charset=utf-8")), Times.Once()); // NOTE: Server timespan is 0, so there should not have been any Add at all. - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Never()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(1)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0")), Times.Never()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(1)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s0"), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -73,7 +73,7 @@ public void not_cache_when_request_not_succes() var result = client.GetAsync(_url + "Get_request_httpResponseException_noCache").Result; _cache.Verify(s => s.Contains(It.IsAny()), Times.Once()); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -83,7 +83,7 @@ public void not_cache_when_request_exception() var result = client.GetAsync(_url + "Get_request_exception_noCache").Result; _cache.Verify(s => s.Contains(It.IsAny()), Times.Once()); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -93,7 +93,7 @@ public void not_cache_add_when_no_content() var result = client.GetAsync(_url + "Get_request_noContent").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_request_nocontent:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -105,8 +105,8 @@ public void set_cache_to_predefined_value_respect_formatter_through_accept_heade var result = client.SendAsync(req).Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -119,8 +119,8 @@ public void set_cache_to_predefined_value_respect_formatter_through_content_type var result = client.SendAsync(req).Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100")), Times.Exactly(1)); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c100_s100"), It.IsAny(), It.IsAny()), Times.Exactly(1)); } [Test] @@ -130,8 +130,8 @@ public void set_cache_dont_exclude_querystring() var result = client.GetAsync(_url + "Get_s50_exclude_false/1?xxx=2").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1&xxx=2:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1&xxx=2:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1&xxx=2:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -141,8 +141,8 @@ public void set_cache_dont_exclude_querystring_duplicate_action_arg_in_querystri var result = client.GetAsync(_url + "Get_s50_exclude_false/1?id=1").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_false"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -155,10 +155,10 @@ public void set_cache_do_exclude_querystring() _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8")), Times.Exactly(2)); //base - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); //actual - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -171,10 +171,10 @@ public void set_cache_do_exclude_querystring_do_not_exclude_action_arg_even_if_p _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8")), Times.Exactly(2)); //base - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); //actual - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_true"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -184,8 +184,8 @@ public void callback_at_the_end_is_excluded_querystring() var result = client.GetAsync(_url + "Get_s50_exclude_fakecallback?id=1&callback=abc").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -195,8 +195,8 @@ public void callback_at_the_beginning_is_excluded_querystring() var result = client.GetAsync(_url + "Get_s50_exclude_fakecallback?callback=abc&id=1").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -206,8 +206,8 @@ public void callback_in_the_middle_is_excluded_querystring() var result = client.GetAsync(_url + "Get_s50_exclude_fakecallback?de=xxx&callback=abc&id=1").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1&de=xxx:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1&de=xxx:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback-id=1&de=xxx:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -217,8 +217,8 @@ public void callback_alone_is_excluded_querystring() var result = client.GetAsync(_url + "Get_s50_exclude_fakecallback?callback=abc").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_s50_exclude_fakecallback"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -230,7 +230,7 @@ public void no_caching_if_user_authenticated_and_flag_set_to_off() Assert.True(result.IsSuccessStatusCode); Assert.IsNull(result.Headers.CacheControl); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } [Test] @@ -275,8 +275,8 @@ public void can_handle_ihttpactionresult_with_default_media_type() var result = client.GetAsync(_url + "Get_ihttpactionresult").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -288,8 +288,8 @@ public void can_handle_ihttpactionresult_with_non_default_media_type() var result = client.SendAsync(req).Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:text/xml; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult:text/xml; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_ihttpactionresult"), It.IsAny(), It.IsAny()), Times.Once()); } @@ -312,8 +312,8 @@ public void will_cache_if_cacheouput_present_on_controller() var result = client.GetAsync("http://www.strathweb.com/api/ignore/cached").Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached:application/json; charset=utf-8")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached:application/json; charset=utf-8"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(100)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.ignorecontroller-cached"), It.IsAny(), It.IsAny()), Times.Once()); } [Test] @@ -323,8 +323,8 @@ public void will_not_cache_if_cacheouput_present_on_controller_but_action_has_ig var result = client.GetAsync("http://www.strathweb.com/api/ignore/uncached").Result; _cache.Verify(s => s.Contains(It.IsAny()), Times.Never()); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); - _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); + _cache.Verify(s => s.Add(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Never()); } //[Test] @@ -346,8 +346,8 @@ public void override_mediatype() var result = client.SendAsync(req).Result; _cache.Verify(s => s.Contains(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image:image/jpeg")), Times.Exactly(2)); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null), Times.Once()); - _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image:image/jpeg"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image")), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), null, It.IsAny(), It.IsAny()), Times.Once()); + _cache.Verify(s => s.Add(It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image:image/jpeg"), It.IsAny(), It.Is(x => x <= DateTime.Now.AddSeconds(50)), It.Is(x => x == "webapi.outputcache.v2.tests.testcontrollers.samplecontroller-get_c50_s50_image"), It.IsAny(), It.IsAny()), Times.Once()); Assert.That(result.Content.Headers.ContentType, Is.EqualTo(new MediaTypeHeaderValue("image/jpeg"))); }