public void expired_in_put() { const string testKey = "TestKey"; const string testValue = "TestValue"; ICache cache = new InProcessCache(); cache.Remove(testKey); cache.Set(testKey, testValue, new TimeSpan(0, 0, 1)); Assert.IsTrue(cache.Exists(testKey)); }
public void expired_at_put() { const string testKey = "TestKey"; const string testValue = "TestValue"; ICache cache = new InProcessCache(); cache.Remove(testKey); cache.Set(testKey, testValue, DateTime.Now.AddMinutes(1)); Assert.IsTrue(cache.Exists(testKey)); }
public void General() { var cache = new InProcessCache(); // ensure no error cache.Remove(Guid.NewGuid().ToString()); Assert.ThrowsAny <ArgumentException>(() => cache.Store(null, 1)); var key = Guid.NewGuid().ToString(); Assert.False(cache.TryGet(key, out var _)); cache.Store(key, this); Assert.True(cache.TryGet(key, out var test)); Assert.Same(this, test); cache.Remove(key); Assert.False(cache.TryGet(key, out var _)); }
public void basic_put_and_get() { const string testKey = "TestKey"; const string testValue = "TestValue"; ICache cache = new InProcessCache(); cache.Remove(testKey); cache.Set(testKey, testValue); var actual = (string)cache.Get(testKey); Assert.AreEqual(testValue, actual); Assert.IsTrue(cache.Exists(testKey)); }