public void TestItemExpiration() { using (var cacheProvider = new CacheProvider <string>((int)TimeSpan.FromMilliseconds(200).TotalMilliseconds)) { const int Key = 123; cacheProvider.Set(Key, "value"); Thread.Sleep(2000); var value = cacheProvider.Get(Key); Assert.IsNull(value, "item must be expired and removed from the cache"); } }
public void TestGet() { using (var cacheProvider = new CacheProvider <string>((int)TimeSpan.FromSeconds(60).TotalMilliseconds)) { const int Key = 123; const string ExpectedValue = "aValue1"; cacheProvider.Set(Key, ExpectedValue); var value = cacheProvider.Get(Key); Assert.AreEqual(ExpectedValue, value); } }