コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }