public void OnTestCompletionShouldUpdateInProgressListWhenTestHasSameId() { long cacheSize = 2; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); for (var i = 0; i < cacheSize; i++) { var tr = this.GetTestResult(i); cache.OnTestStarted(tr.TestCase); var clone = new TestCase( tr.TestCase.FullyQualifiedName, tr.TestCase.ExecutorUri, tr.TestCase.Source); clone.Id = tr.TestCase.Id; Assert.IsTrue(cache.OnTestCompletion(clone)); Assert.AreEqual(0, cache.InProgressTests.Count); } }
public void OnTestStartedShouldAddToInProgressTests() { var tester = new TestCacheTester { ExpectedCacheSize = int.MaxValue }; var cache = new TestRunCache(int.MaxValue, TimeSpan.MaxValue, tester.CacheHitOnSize); var tr = this.GetTestResult(0); cache.OnTestStarted(tr.TestCase); CollectionAssert.Contains(cache.InProgressTests.ToList(), tr.TestCase); }
public void OnTestStartedShouldAddMultipleInProgressTestsTillCacheHit() { long cacheSize = 10; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); for (var i = 0; i < (cacheSize - 1); i++) { var tr = this.GetTestResult(i); cache.OnTestStarted(tr.TestCase); Assert.AreEqual(i, cache.InProgressTests.Count - 1); } }
public void OnTestCompletionShouldUpdateInProgressList() { long cacheSize = 2; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); for (int i = 0; i < cacheSize; i++) { var tr = this.GetTestResult(i); cache.OnTestStarted(tr.TestCase); Assert.IsTrue(cache.OnTestCompletion(tr.TestCase)); Assert.AreEqual(0, cache.InProgressTests.Count); } }
public void OnNewTestResultShouldRemoveTestCaseFromInProgressList() { long cacheSize = 10; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); for (var i = 0; i < 2; i++) { var tr = this.GetTestResult(i); cache.OnTestStarted(tr.TestCase); cache.OnNewTestResult(tr); } Assert.AreEqual(0, cache.InProgressTests.Count); }
public void OnTestCompleteShouldNotRemoveTestCaseFromInProgressListForUnrelatedTestResult() { long cacheSize = 10; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); var tr1 = this.GetTestResult(0); cache.OnTestStarted(tr1.TestCase); var tr2 = this.GetTestResult(1); Assert.IsFalse(cache.OnTestCompletion(tr2.TestCase)); Assert.AreEqual(1, cache.InProgressTests.Count); }
public void OnTestStartedShouldReportResultsOnCacheHit() { long cacheSize = 2; var tester = new TestCacheTester { ExpectedCacheSize = cacheSize }; var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize); for (var i = 0; i < cacheSize; i++) { var tr = this.GetTestResult(i); cache.OnTestStarted(tr.TestCase); } Assert.AreEqual(1, tester.CacheHitCount); Assert.AreEqual(0, cache.TotalExecutedTests); Assert.AreEqual(0, cache.TestResults.Count); Assert.AreEqual(0, cache.InProgressTests.Count); Assert.AreEqual(2, tester.TotalInProgressTestsReceived); }