Пример #1
0
        public void TestRunStatsShouldReturnCurrentStats()
        {
            long cacheSize = 10;
            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);
                if (i < 5)
                {
                    tr.Outcome = TestOutcome.Passed;
                }
                else
                {
                    tr.Outcome = TestOutcome.Failed;
                }

                cache.OnNewTestResult(tr);
            }

            var stats = cache.TestRunStatistics;

            Assert.AreEqual(cacheSize, stats.ExecutedTests);
            Assert.AreEqual(5, stats.Stats[TestOutcome.Passed]);
            Assert.AreEqual(5, stats.Stats[TestOutcome.Failed]);
        }
Пример #2
0
        public void OnNewTestResultShouldAddToTestResultCache()
        {
            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.OnNewTestResult(tr);
                CollectionAssert.Contains(cache.TestResults.ToList(), tr);
            }
        }
Пример #3
0
        public void OnNewTestResultShouldAddToTotalExecutedTests()
        {
            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.OnNewTestResult(tr);
            }

            Assert.AreEqual(2, cache.TotalExecutedTests);
        }
Пример #4
0
        public void GetLastChunkShouldResetTestResultsInCache()
        {
            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.OnNewTestResult(tr);
            }

            cache.GetLastChunk();
            Assert.AreEqual(0, cache.TestResults.Count);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public void OnNewTestResultShouldReportTestResultsWhenMaxCacheSizeIsHit()
        {
            long cacheSize = 10;
            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.OnNewTestResult(tr);
            }

            Assert.AreEqual(1, tester.CacheHitCount);
            Assert.AreEqual(cacheSize, cache.TotalExecutedTests);
            Assert.AreEqual(0, cache.TestResults.Count);
        }
Пример #7
0
        public void OnNewTestResultShouldUpdateRunStats()
        {
            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);
                tr.Outcome = TestOutcome.Passed;
                cache.OnNewTestResult(tr);
            }

            Assert.AreEqual(2, cache.TestRunStatistics.ExecutedTests);
            Assert.AreEqual(2, cache.TestRunStatistics.Stats[TestOutcome.Passed]);
        }
Пример #8
0
        public void OnNewTestResultShouldReportResultsMultipleTimes()
        {
            long cacheSize = 10;
            var  tester    = new TestCacheTester {
                ExpectedCacheSize = cacheSize
            };

            var  cache         = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize);
            long executedTests = 45;

            for (var i = 0; i < executedTests; i++)
            {
                var tr = this.GetTestResult(i);
                cache.OnNewTestResult(tr);
            }

            Assert.AreEqual(4, tester.CacheHitCount);
            Assert.AreEqual(executedTests, cache.TotalExecutedTests);
            Assert.AreEqual(5, cache.TestResults.Count);
        }
Пример #9
0
        public void OnNewTestResultShouldNotFireIfMaxCacheSizeIsNotHit()
        {
            long cacheSize = 10;
            var  tester    = new TestCacheTester {
                ExpectedCacheSize = cacheSize
            };

            var cache         = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize);
            var executedTests = cacheSize - 1;

            for (var i = 0; i < executedTests; i++)
            {
                var tr = this.GetTestResult(i);
                cache.OnNewTestResult(tr);
            }

            Assert.AreEqual(0, tester.CacheHitCount);
            Assert.AreEqual(executedTests, cache.TotalExecutedTests);
            Assert.AreEqual(executedTests, cache.TestResults.Count);
        }
Пример #10
0
        public void GetLastChunkShouldReturnTestResultsInCache()
        {
            long cacheSize = 10;
            var  tester    = new TestCacheTester {
                ExpectedCacheSize = cacheSize
            };

            var cache = new TestRunCache(cacheSize, TimeSpan.MaxValue, tester.CacheHitOnSize);
            List <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult> pushedTestResults = new List <Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult>();

            for (var i = 0; i < 2; i++)
            {
                var tr = this.GetTestResult(i);
                cache.OnNewTestResult(tr);
                pushedTestResults.Add(tr);
            }

            var testResultsInCache = cache.GetLastChunk();

            CollectionAssert.AreEqual(pushedTestResults, testResultsInCache.ToList());
        }