Beispiel #1
0
        public void should_throw_exception_when_batch_isnt_found()
        {
            // given
            var testFileQueue = new TestFileQueueStub();
            var memoryCache   = new MemoryCache("test");
            var resultFactory = new Mock <ITestFileResultFactory>();

            // when
            var batchManager = new BatchManager(testFileQueue, memoryCache, resultFactory.Object);

            // then
            Assert.Throws <KeyNotFoundException>(() => batchManager.GetBatchStatus(1));
        }
Beispiel #2
0
        public void should_return_expected_batch_status_when_tests_pass()
        {
            // given
            const int batchId       = 8;
            var       testFileQueue = new Mock <ITestFileQueue>();
            var       memoryCache   = new MemoryCache("test");
            var       resultFactory = new Mock <ITestFileResultFactory>();

            memoryCache.Set($"{BatchManager.KeyPrefix}{batchId}", new List <int> {
                5
            }, DateTimeOffset.MaxValue);
            var testFileInfo = new TestFileRunnerTaskInfo(5);

            testFileQueue
            .Setup(x => x.GetTestFileTaskInfo(5))
            .Returns(testFileInfo);

            TestFileRunResult runResult = GenerateStubTestFileResult();

            resultFactory
            .Setup(x => x.Create(testFileInfo, false, TimeSpan.Zero))
            .Returns(runResult);

            // when
            var         batchManager = new BatchManager(testFileQueue.Object, memoryCache, resultFactory.Object);
            BatchStatus batchStatus  = batchManager.GetBatchStatus(batchId);

            // then
            Assert.That(batchStatus, Is.Not.Null);
            Assert.That(batchStatus.BatchId, Is.EqualTo(batchId));
            Assert.That(batchStatus.TestFilesResultIds.First(), Is.EqualTo(runResult.ResultId));
            Assert.That(batchStatus.BatchFinished, Is.True);
            Assert.That(batchStatus.HasFailedTests, Is.False);
            Assert.That(batchStatus.TestFilesRunning, Is.EqualTo(0));
            Assert.That(batchStatus.TestFilesFinished, Is.EqualTo(1));
            Assert.That(batchStatus.TestFilesWithFailedTests, Is.Empty);
            Assert.That(batchStatus.TestFilesFailed, Is.EqualTo(0));
            Assert.That(batchStatus.FailedTasks, Is.Empty);
        }