public void DefaultConfigMemCache_Get_ExistingCacheRetrieved() { var test1 = new CacheTest1(); var test2 = new CacheTest2(); DefaultConfigMemCache cache = new DefaultConfigMemCache(); cache.Cache("Test1", new CacheInformation() { Value = test1, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); cache.Cache("Test2", new CacheInformation() { Value = test2, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); var results = cache.Get("Test1"); Assert.AreEqual(test1, results, "Should be the same item in as out"); }
public void DefaultConfigMemCache_ClearSingleCache_AllRecordsRemoved() { var test1 = new CacheTest1(); var test2 = new CacheTest2(); DefaultConfigMemCache cache = new DefaultConfigMemCache(); cache.Cache("Test1", new CacheInformation() { Value = test1, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); cache.Cache("Test2", new CacheInformation() { Value = test2, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); cache.Clear("Test2"); Assert.AreEqual(cache.Get("Test1"), test1, "Test 1 should exist in cache"); Assert.IsNull(cache.Get("Test2"), "Test 2 shouldnot exist in cache due to clear"); }
public void DefaultConfigMemCache_GetCache_ExistingCacheRetrieved() { var test1 = new CacheTest1(); var test2 = new CacheTest2(); DefaultConfigMemCache cache = new DefaultConfigMemCache(); cache.Cache("Test1", new CacheInformation() { Value = test1, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); cache.Cache("Test2", new CacheInformation() { Value = test2, Duration = new TimeSpan(999, 0, 0) }, (a, b) => { }); var results = cache.GetCache("Test1", () => { Assert.Fail("Item should be present as it was cached previously."); return(null); }, (a, b) => { }); Assert.AreEqual(test1, results, "Should be the same item in as out"); }