public async Task ToCachedCollection_Async_EmptyKeyResolvesQuery(string ck) { var a = new[] { "a", "b", "c" }; var q = Task.FromResult(a.AsQueryable()); var cm = new Mock <ICacheManager>(); var res = await CacheManagerExtensions.ToCachedCollection(cm.Object, q, ck, TimeSpan.FromDays(1)); res.ShouldBe(a); }
public async Task ToCachedCollection_Async_GetsFromCache() { var ck = "cKey"; var a = new List <string> { "a", "b", "c" }; var cm = new Mock <ICacheManager>(); cm.Setup(c => c.Get(It.IsAny <string>(), It.IsAny <Func <Task <ICollection <string> > > >(), It.IsAny <TimeSpan>())) .ReturnsAsync(a); var q = Task.FromResult(a.AsQueryable()); var res = await CacheManagerExtensions.ToCachedCollection(cm.Object, q, ck, TimeSpan.FromDays(1)); res.ShouldBe(a); }