Exemplo n.º 1
0
        public void Get_Single_From_Cache()
        {
            var cache = new Mock <IRuntimeCacheProvider>();

            cache.Setup(x => x.GetCacheItem(It.IsAny <string>())).Returns(new AuditItem(1, "blah", AuditType.Copy, 123));

            var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, new RepositoryCachePolicyOptions());

            var found = defaultPolicy.Get(1, id => null, ids => null);

            Assert.IsNotNull(found);
        }
        public void Get_Single_From_Cache()
        {
            var cache = new Mock <IAppPolicyCache>();

            cache.Setup(x => x.Get(It.IsAny <string>())).Returns(new AuditItem(1, AuditType.Copy, 123, "test", "blah"));

            var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());

            AuditItem found = defaultPolicy.Get(1, id => null, ids => null);

            Assert.IsNotNull(found);
        }
        public void Caches_Single()
        {
            var isCached = false;
            var cache    = new Mock <IAppPolicyCache>();

            cache.Setup(x => x.Insert(It.IsAny <string>(), It.IsAny <Func <object> >(), It.IsAny <TimeSpan?>(), It.IsAny <bool>(), It.IsAny <string[]>()))
            .Callback(() => isCached = true);

            var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions());

            AuditItem unused = defaultPolicy.Get(1, id => new AuditItem(1, AuditType.Copy, 123, "test", "blah"), o => null);

            Assert.IsTrue(isCached);
        }
Exemplo n.º 4
0
        public void Caches_Single()
        {
            var isCached = false;
            var cache    = new Mock <IRuntimeCacheProvider>();

            cache.Setup(x => x.InsertCacheItem(It.IsAny <string>(), It.IsAny <Func <object> >(), It.IsAny <TimeSpan?>(), It.IsAny <bool>(),
                                               It.IsAny <CacheItemPriority>(), It.IsAny <CacheItemRemovedCallback>(), It.IsAny <string[]>()))
            .Callback(() =>
            {
                isCached = true;
            });

            var defaultPolicy = new DefaultRepositoryCachePolicy <AuditItem, object>(cache.Object, new RepositoryCachePolicyOptions());

            var found = defaultPolicy.Get(1, id => new AuditItem(1, "blah", AuditType.Copy, 123), o => null);

            Assert.IsTrue(isCached);
        }