Пример #1
0
            private ICacheEvent DuplicateEvent(ICacheEvent cacheEvent)
            {
                SettableCacheEvent copyEvent = SettableCacheEvent.Obtain();

                copyEvent.SetCacheKey(cacheEvent.CacheKey);
                copyEvent.SetCacheLimit(cacheEvent.CacheLimit);
                copyEvent.SetCacheSize(cacheEvent.CacheSize);
                copyEvent.SetEvictionReason(cacheEvent.EvictionReason);
                copyEvent.SetException(cacheEvent.Exception);
                copyEvent.SetItemSize(cacheEvent.ItemSize);
                copyEvent.SetResourceId(cacheEvent.ResourceId);
                return(copyEvent);
            }
        public void TestRecycleClearsAllFields()
        {
            SettableCacheEvent cacheEvent = SettableCacheEvent.Obtain();

            cacheEvent.SetCacheKey(default(ICacheKey));
            cacheEvent.SetCacheLimit(21);
            cacheEvent.SetCacheSize(12332445);
            cacheEvent.SetEvictionReason(EvictionReason.CACHE_MANAGER_TRIMMED);
            cacheEvent.SetException(new IOException());
            cacheEvent.SetItemSize(1435);
            cacheEvent.SetResourceId("sddqrtyjf");

            cacheEvent.Recycle();

            Assert.IsNull(cacheEvent.CacheKey);
            Assert.AreEqual(cacheEvent.CacheLimit, 0);
            Assert.AreEqual(cacheEvent.CacheSize, 0);
            Assert.AreEqual(cacheEvent.EvictionReason, EvictionReason.NONE);
            Assert.IsNull(cacheEvent.Exception);
            Assert.AreEqual(cacheEvent.ItemSize, 0);
            Assert.IsNull(cacheEvent.ResourceId);
        }