Exemple #1
0
        private async Task ProcessTestRun(TestRunReadModel testRun)
        {
            TestReadModel test;

            using (var scope = _serviceScopeFactory.CreateScope())
            {
                var testsRepository = scope.ServiceProvider.GetRequiredService <AppKeyRepository <Test> >();
                test = testsRepository.Read <TestReadModel>().SingleOrDefault(t => t.Id == testRun.TestId);
            }

            _processingRunData.CurrentTestName = test.Name;
            SendRunData();

            var currentStep    = TestRunStepHelper.GetFirstStep() as TestRunStep?;
            var testRunOutcome = RunOutcome.Ok;

            while (currentStep.HasValue)
            {
                var stepOutcome = await ProcessTestRunStep(currentStep.Value, test, testRun);

                currentStep = TestRunStepHelper.GetNextStep(currentStep.Value);

                testRunOutcome = testRunOutcome == RunOutcome.Ok && stepOutcome == RunOutcome.Ok ? RunOutcome.Ok : RunOutcome.Wrong;
            }

            using (var scope = _serviceScopeFactory.CreateScope())
            {
                var testRunsRepository = scope.ServiceProvider.GetRequiredService <AppKeyRepository <TestRun> >();
                await testRunsRepository.UpdateAsync(tr => tr.Id == testRun.Id, tr =>
                {
                    tr.HasBeenProcessed = true;
                    tr.Outcome          = testRunOutcome;
                });

                var runsRepository = scope.ServiceProvider.GetRequiredService <AppKeyRepository <Run> >();
                await runsRepository.UpdateAsync(r => r.Id == ProcessingRun.Id, r =>
                {
                    var newOutcome = r.Outcome == RunOutcome.Ok && testRunOutcome == RunOutcome.Ok ? RunOutcome.Ok : RunOutcome.Wrong;

                    r.ProcessedTestsCount++;
                    r.Outcome = newOutcome;

                    _processingRunData.Outcome = newOutcome;
                });
            }

            if (testRunOutcome == RunOutcome.Ok)
            {
                _processingRunData.OkTestsCount++;
            }
            else
            {
                _processingRunData.WrongTestsCount++;
            }

            _processingRunData.CurrentTestName = null;
            _processingRunData.ProcessedTestsCount++;
            _processingRunData.CurrentTestStepIndex = null;
            SendRunData();
        }
Exemple #2
0
        private async Task <RunOutcome> ProcessTestRunStep(TestRunStep step, TestReadModel test, TestRunReadModel testRun)
        {
            _processingRunData.CurrentTestStep      = step;
            _processingRunData.CurrentTestStepIndex = TestRunStepHelper.GetStepIndex(step);
            SendRunData();

            var started = DateTime.Now;

            var items = new List <TestRunStepItem>();

            switch (step)
            {
            case TestRunStep.GenerateInputFiles:
                items = await GenerateInputFiles(test, testRun);

                break;

            case TestRunStep.GenerateExeOutputFiles:
                items = await GenerateExeOutputFiles(test, testRun);

                break;

            case TestRunStep.GenerateCilAntroOutputFiles:
                items = await GenerateCilAntroOutputFiles(test, testRun);

                break;

            case TestRunStep.CompareOutputFiles:
                items = await CompareOutputs(test, testRun);

                break;
            }

            _processingRunData.CurrentItemIndex = null;
            _processingRunData.CurrentItemName  = null;
            SendRunData();

            var finished = DateTime.Now;

            var outcome = items.All(i => i.Outcome == RunOutcome.Ok) ? RunOutcome.Ok : RunOutcome.Wrong;

            var newStepInfo = new TestRunStepInfo
            {
                Id = Guid.NewGuid(),
                ProcessedForMilliseconds = (int)(finished - started).TotalMilliseconds,
                Step      = step,
                TestRunId = testRun.Id,
                Items     = items,
                Outcome   = outcome
            };

            using (var scope = _serviceScopeFactory.CreateScope())
            {
                var stepsRepository = scope.ServiceProvider.GetRequiredService <AppKeyRepository <TestRunStepInfo> >();
                await stepsRepository.CreateAsync(newStepInfo);
            }

            return(outcome);
        }
Exemple #3
0
 public RunData(RunReadModel run)
 {
     Status                   = run.Status;
     Outcome                  = run.Outcome;
     ProcessedTestsCount      = run.ProcessedTestsCount;
     ProcessedForMilliseconds = run.ProcessedForMilliseconds;
     TestStepsCount           = TestRunStepHelper.GetAllSteps().Count;
 }