Пример #1
0
        public void Set_Remove()
        {
            string cacheKey = "Set_Remove";

            handler.Remove(cacheKey);

            List <Item>    items = GetNewItems(10);
            HashSet <Item> set   = new HashSet <Item>(items);

            handler.Register(cacheKey, new Func <ISet <Item> >(() => set), TimeSpan.FromMinutes(30));

            if (handler.CacheEnabled)
            {
                foreach (var item in items)
                {
                    var exists = handler.SetExists(cacheKey, item);
                    Assert.AreEqual(true, exists);
                }
            }
            foreach (var item in items)
            {
                handler.SetRemove(cacheKey, item);
            }

            foreach (var item in items)
            {
                var exists = handler.SetExists(cacheKey, item);
                Assert.AreEqual(false, exists);
            }
            handler.Remove(cacheKey);
        }