Пример #1
0
        public void Can_Remove_By_Strong_Type()
        {
            var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
            var cacheContent2 = new MacroCacheContent(new LiteralControl(), "Test2");
            var cacheContent3 = new MacroCacheContent(new LiteralControl(), "Test3");
            var cacheContent4 = new MacroCacheContent(new LiteralControl(), "Test4");
            _helper.InsertCacheItem("Test1", CacheItemPriority.Default, new TimeSpan(0, 0, 60), () => cacheContent1);
            _helper.InsertCacheItem("Test2", CacheItemPriority.Default, new TimeSpan(0, 0, 60), () => cacheContent2);
            _helper.InsertCacheItem("Test3", CacheItemPriority.Default, new TimeSpan(0, 0, 60), () => cacheContent3);
            _helper.InsertCacheItem("Test4", CacheItemPriority.Default, new TimeSpan(0, 0, 60), () => cacheContent4);

            Assert.AreEqual(4, HttpRuntime.Cache.Count);

            _helper.ClearCacheObjectTypes<MacroCacheContent>();

            Assert.AreEqual(0, HttpRuntime.Cache.Count);
        }
Пример #2
0
        public void Can_Clear_By_Search()
        {
            var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
            var cacheContent2 = new MacroCacheContent(new LiteralControl(), "Test2");
            var cacheContent3 = new MacroCacheContent(new LiteralControl(), "Test3");
            var cacheContent4 = new LiteralControl();
            Provider.GetCacheItem("Test1", () => cacheContent1);
            Provider.GetCacheItem("Tester2", () => cacheContent2);
            Provider.GetCacheItem("Tes3", () => cacheContent3);
            Provider.GetCacheItem("different4", () => cacheContent4);

            Assert.AreEqual(4, GetTotalItemCount);

            Provider.ClearCacheByKeySearch("Test");

            Assert.AreEqual(2, GetTotalItemCount);
        }
Пример #3
0
        public void Can_Remove_By_Strong_Type()
        {
            var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
            var cacheContent2 = new MacroCacheContent(new LiteralControl(), "Test2");
            var cacheContent3 = new MacroCacheContent(new LiteralControl(), "Test3");
            var cacheContent4 = new LiteralControl();
            Provider.GetCacheItem("Test1", () => cacheContent1);
            Provider.GetCacheItem("Test2", () => cacheContent2);
            Provider.GetCacheItem("Test3", () => cacheContent3);
            Provider.GetCacheItem("Test4", () => cacheContent4);

            Assert.AreEqual(4, GetTotalItemCount);

            Provider.ClearCacheObjectTypes<MacroCacheContent>();

            Assert.AreEqual(1, GetTotalItemCount);
        }
Пример #4
0
        public void Can_Remove_By_Type_Name()
        {
            var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
            var cacheContent2 = new MacroCacheContent(new LiteralControl(), "Test2");
            var cacheContent3 = new MacroCacheContent(new LiteralControl(), "Test3");
            var cacheContent4 = new LiteralControl();
            Provider.GetCacheItem("Test1", () => cacheContent1);
            Provider.GetCacheItem("Test2", () => cacheContent2);
            Provider.GetCacheItem("Test3", () => cacheContent3);
            Provider.GetCacheItem("Test4", () => cacheContent4);

            Assert.AreEqual(4, GetTotalItemCount);

            //Provider.ClearCacheObjectTypes("umbraco.MacroCacheContent");
            Provider.ClearCacheObjectTypes(typeof(MacroCacheContent).ToString());

            Assert.AreEqual(1, GetTotalItemCount);
        }
Пример #5
0
 public void Can_Get_When_Available()
 {
     var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
     var result = Provider.GetCacheItem("Test1", () => cacheContent1);
     var result2 = Provider.GetCacheItem("Test1", () => cacheContent1);
     Assert.AreEqual(1, GetTotalItemCount);
     Assert.AreEqual(result, result2);
 }
Пример #6
0
        public void Can_Clear_All_Items()
        {
            var cacheContent1 = new MacroCacheContent(new LiteralControl(), "Test1");
            var cacheContent2 = new MacroCacheContent(new LiteralControl(), "Test2");
            var cacheContent3 = new MacroCacheContent(new LiteralControl(), "Test3");
            var cacheContent4 = new LiteralControl();
            Provider.GetCacheItem("Test1", () => cacheContent1);
            Provider.GetCacheItem("Test2", () => cacheContent2);
            Provider.GetCacheItem("Test3", () => cacheContent3);
            Provider.GetCacheItem("Test4", () => cacheContent4);

            Assert.AreEqual(4, GetTotalItemCount);

            Provider.ClearAllCache();

            Assert.AreEqual(0, GetTotalItemCount);
        }