public void CacheCapacityTest() { using (new ReportCacheTestInitializer(_testDocumentContainer)) { // Tests that the cache kicks out the LRU report when it reaches its capacity ToolReportCache.Instance.Register(_testDocumentContainer); ToolReportCache.Instance.TestMaximumSize = Convert.ToInt32(ToolReportCache.ReportSize(REPORT_STRING) * 2.5); ToolReportCache.Instance.TestReport = REPORT_STRING; // add two reports to the cache ToolReportCache.Instance.GetReport(null, _report1, null); ToolReportCache.Instance.GetReport(null, _report2, null); // the cache is now 80% full, adding one more report should cause it to exceed capacity Assert.IsTrue(ToolReportCache.Instance.IsLast(_report1)); ToolReportCache.Instance.GetReport(null, _report3, null); Assert.IsFalse(ToolReportCache.Instance.ContainsKey(_report1)); } }
public ReportCacheTestInitializer(IDocumentContainer testDocumentContainer) { _reportCache = ToolReportCache.Instance; _reportCache.Register(testDocumentContainer); _reportCache.TestReport = REPORT_STRING; }