public void DatabaseCacheAllAroundTest() { _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString(); Cleanup(); var seed = new Seed32(); var cleanEntities = TestResourceFactory.GetMockClassAObjects(500); var dirtyEntities = TestResourceFactory.GetMockClassAObjects(500); cleanEntities.ToList().ForEach(c => c.Id = seed.Increment()); dirtyEntities.ToList().ForEach(d => d.Id = seed.Increment()); var db = new DatabaseCache<int, MockClassA>(false, 2048, new BinConverter32()); db.CacheItem(cleanEntities.First().Id); //with manual caching foreach (var e in cleanEntities) db.UpdateCache(e.Id, e, false, false); Assert.AreEqual(1, db.Count); Assert.IsTrue(db.Contains(cleanEntities.First().Id)); Assert.AreEqual(cleanEntities.First().Name, db.GetFromCache(cleanEntities.First().Id).Name); //with autoCache foreach (var e in cleanEntities) db.UpdateCache(e.Id, e, true, false); Assert.AreEqual(500, db.Count); db.Detach(cleanEntities.First().Id); Assert.AreEqual(499, db.Count); Assert.IsFalse(db.Contains(cleanEntities.First().Id)); Assert.IsNull(db.GetFromCache(cleanEntities.First().Id)); db.CacheSize = 400; db.UpdateCache(cleanEntities.First().Id, cleanEntities.First(), true, false); Assert.AreEqual(201, db.Count); Assert.IsFalse(db.IsNew(cleanEntities.First().Id)); db.ClearCache(); Assert.AreEqual(0, db.Count); }