public void ReferenceType() { var key = "key-object"; ICacheProvider cache = new HttpContextCacheProvider(); var id1 = new Object(); var id2 = cache.GetOrCreate(key, () => id1); Assert.AreEqual(id1, id2); cache.Expire(key); Object id3; var exist = cache.TryGet(key, out id3); Assert.IsFalse(exist); Assert.AreNotEqual(id1, id3); Assert.AreEqual(id3, null); }
public void ValueType() { var key = "key-guid"; ICacheProvider cache = new HttpContextCacheProvider(); var id1 = Guid.NewGuid(); var id2 = cache.GetOrCreate(key, () => id1); Assert.AreEqual(id1, id2); cache.Expire(key); Guid id3; var exist = cache.TryGet(key, out id3); Assert.IsFalse(exist); Assert.AreNotEqual(id1, id3); Assert.AreEqual(id3, Guid.Empty); }