public void TryGetTest1() { TimedCache<int, object> cache = new TimedCache<int, object>(new TimeSpan(0, 1, 0)); object o = null; Assert.IsFalse(cache.TryGet(1, ref o)); Assert.IsNull(o); cache.Set(1, o); Assert.IsTrue(cache.TryGet(1, ref o)); Assert.IsNull(o); o = new object(); cache.Set(1, o); Assert.IsTrue(cache.TryGet(1, ref o)); Assert.IsNotNull(o); }
public void TryGetTest2() { TimedCache<int, int> cache = new TimedCache<int, int>(new TimeSpan(0, 1, 0)); int output = 5; Assert.IsFalse(cache.TryGet(1, ref output)); Assert.AreEqual(5, output); cache.Set(10, output); int output2 = Int32.MinValue; Assert.IsTrue(cache.TryGet(10, ref output2)); Assert.AreEqual(5, output2); output = 15; cache.Set(10, output); int output3 = Int32.MinValue; Assert.IsTrue(cache.TryGet(10, ref output3)); Assert.AreEqual(15, output3); }