public void FlushRequestAndUnloadDirtyTest() { _testName = MethodInfo.GetCurrentMethod().Name.GetHashCode().ToString(); Cleanup(); var seed = new Seed32(); var dirtyEntities = TestResourceFactory.GetMockClassAObjects(500); dirtyEntities.ToList().ForEach(d => d.Id = seed.Increment()); var db = new DatabaseCache<int, MockClassA>(false, 2048, new BinConverter32()); db.CacheSize = 400; db.FlushRequested += new EventHandler(delegate(object sender, EventArgs e) { var dbparam = sender as DatabaseCache<int, MockClassA>; Assert.AreEqual(dbparam.CacheSize + 1, dbparam.DirtyCount); var dirtyItems = dbparam.UnloadDirtyItems(); Assert.AreEqual(0, dbparam.DirtyCount); Assert.AreEqual(0, dbparam.Count); }); foreach (var d in dirtyEntities) db.UpdateCache(d.Id, d, true, true); db.Sweep(); }