示例#1
0
        public void CustomObject_Add()
        {
            string key = DateTime.UtcNow.ToOADate().ToString();

            handler.Register <Item>(key, () => new Item()
            {
                ID = 1, Name = "Bill"
            }, TimeSpan.FromSeconds(30));

            Assert.AreEqual(handler.CacheEnabled, handler.Exists(key));
            if (handler.CacheEnabled)
            {
                var val = handler.Retrieve <Item>(key);
                Assert.IsNotNull(val);
                Assert.AreEqual(1, val.ID);
                Assert.AreEqual("Bill", val.Name);
            }

            handler.Remove(key);
            Assert.AreEqual(false, handler.Exists(key));
        }