public void returns_all_keys_in_cache() { IApiOutputCache cache = new MemoryCacheDefault(); cache.Add("base", "abc", DateTime.Now.AddSeconds(60)); cache.Add("key1", "abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key2", "abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key3", "abc", DateTime.Now.AddSeconds(60), "base"); var result = cache.AllKeys; CollectionAssert.AreEquivalent(new[] { "base", "key1", "key2", "key3" }, result); }
public void cache_singleton() { var cache = new MemoryCacheDefault(); var conf = new HttpConfiguration(); conf.CacheOutputConfiguration().RegisterCacheOutputProvider(() => cache); object cache1; conf.Properties.TryGetValue(typeof(IApiOutputCache), out cache1); object cache2; conf.Properties.TryGetValue(typeof(IApiOutputCache), out cache2); Assert.AreSame(((Func<IApiOutputCache>)cache1)(), ((Func<IApiOutputCache>)cache2)()); }
public void cache_singleton() { var cache = new MemoryCacheDefault(); var conf = new HttpConfiguration(); conf.CacheOutputConfiguration().RegisterCacheOutputProvider(() => cache); object cache1; conf.Properties.TryGetValue(typeof(IApiOutputCache), out cache1); object cache2; conf.Properties.TryGetValue(typeof(IApiOutputCache), out cache2); Assert.AreSame(((Func <IApiOutputCache>)cache1)(), ((Func <IApiOutputCache>)cache2)()); }
public void remove_startswith_cascades_to_all_dependencies() { IApiOutputCache cache = new MemoryCacheDefault(); cache.Add("base", "abc", DateTime.Now.AddSeconds(60)); cache.Add("key1","abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key2", "abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key3", "abc", DateTime.Now.AddSeconds(60), "base"); Assert.IsNotNull(cache.Get("key1")); Assert.IsNotNull(cache.Get("key2")); Assert.IsNotNull(cache.Get("key3")); cache.RemoveStartsWith("base"); Assert.IsNull(cache.Get("base")); Assert.IsNull(cache.Get("key1")); Assert.IsNull(cache.Get("key2")); Assert.IsNull(cache.Get("key3")); }
public void remove_startswith_cascades_to_all_dependencies() { IApiOutputCache cache = new MemoryCacheDefault(); cache.Add("base", "abc", DateTime.Now.AddSeconds(60)); cache.Add("key1", "abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key2", "abc", DateTime.Now.AddSeconds(60), "base"); cache.Add("key3", "abc", DateTime.Now.AddSeconds(60), "base"); Assert.IsNotNull(cache.Get("key1")); Assert.IsNotNull(cache.Get("key2")); Assert.IsNotNull(cache.Get("key3")); cache.RemoveStartsWith("base"); Assert.IsNull(cache.Get("base")); Assert.IsNull(cache.Get("key1")); Assert.IsNull(cache.Get("key2")); Assert.IsNull(cache.Get("key3")); }