예제 #1
0
파일: CacheTests.cs 프로젝트: nevergofull/A
        public void Dictionary_RemoveExisting()
        {
            string cacheKey = "Dictionary_RemoveExisting";

            handler.Remove(cacheKey);

            List <Item> items = GetNewItems(10);

            handler.Register(cacheKey, new Func <IDictionary <object, Item> >(() => items.ToDictionary(new Func <Item, object>(x => x.ID))), TimeSpan.FromMinutes(30));

            //replace existing key
            var newItem = new Item()
            {
                ID = 1, Count = 400, Name = "New Name"
            };

            handler.DictionaryRemove(cacheKey, 1);

            var cachedItem = handler.DictionaryRetrieve <int, Item>(cacheKey, 1);

            Assert.IsNull(cachedItem);

            handler.Remove(cacheKey);
        }