public void GetKey_ShouldPrependGenericArgs() { var cache = new SimpleCachePassThrough("someKeyPrefix"); cache.GetKey <Dictionary <string, object> >("somevalue") .ShouldEqual("someKeyPrefix.Dictionary<String, Object>.somevalue"); }
public void SimpleCachePassThrough_ShouldCacheSerializableObjects() { var cache = new SimpleCachePassThrough(); var obj = cache.Get("key", () => new Dictionary <string, object>()); obj.ShouldNotBeNull(); }
public void SimpleCachePassThrough_ShouldNotCacheUnserializableObjects() { var cache = new SimpleCachePassThrough(); cache.Get("key", () => { IDictionary <string, object> stored = new ExpandoObject(); stored["key"] = "Some other object"; return(new List <IDictionary <string, object> > { stored }); }); }
public async Task SimpleCache_ShouldBeThreadsafe() { var cache = new SimpleCachePassThrough(); var tasks = new List <Task>(); for (var i = 0; i < 1000; i++) { var task = Task.Run(() => 100.Times(j => { cache.Add("SomeKey", "SomeValue"); cache.Remove <string>("SomeKey"); })); tasks.Add(task); } await Task.WhenAll(tasks); string value; cache.TryGetValue("SomeKey", out value).ShouldBeFalse(); }
public void GetKey_ShouldPrependKeyPrefix() { var cache = new SimpleCachePassThrough("someKeyPrefix"); cache.GetKey <string>("somevalue").ShouldEqual("someKeyPrefix.String.somevalue"); }
public void GetKey_ShouldPrependTypeName() { var cache = new SimpleCachePassThrough(); cache.GetKey <string>("somevalue").ShouldEqual("String.somevalue"); }