public DbCleanupJob(IConfiguration configuration, ITestFileResultRepository repository) { _configuration = configuration; _repository = repository; }
public TestsController(ITestRepository testRepository, ITestFileResultRepository testFileResultRepository) { _testRepository = testRepository; _testFileResultRepository = testFileResultRepository; }
public async Task <TestFileResult> RunAsync(TestFile testFile, string environment, string username) { _isStopPending = false; lock (_currentResults) { _currentResults = new List <TestResult>(); } var testFileResult = new TestFileResult { Id = SessionId, Filename = testFile.Filename, StartTime = DateTime.UtcNow, Environment = environment, Username = username }; // Add all config variables and ones in this <test> ICapturedVariableProvider variables = _capturedVariableProviderFactory.Create(environment); variables.AddOrUpdateVariables(testFile.Variables); var verificationsMatcher = new AssertionsMatcher(variables, _loggerFactory.CreateLogger()); List <Test> tests = testFile.Tests.ToList(); TimeSpan minResponseTime = TimeSpan.MaxValue; TimeSpan maxResponseTime = TimeSpan.MinValue; int totalTestsRun = 0; TestsRun = 0; TotalTests = tests.Count; bool shouldSave = true; for (int i = 0; i < tests.Count; i++) { if (_isStopPending) { break; } try { TestResult result = await RunTestAsync(tests.ElementAt(i), i, variables, verificationsMatcher); AddResult(testFileResult, result); if (result.ResponseTime < minResponseTime) { minResponseTime = result.ResponseTime; } if (result.ResponseTime > maxResponseTime) { maxResponseTime = result.ResponseTime; } } catch (Exception ex) { ReportError(ex); } finally { totalTestsRun++; TestsRun++; } if (_isStopPending) { shouldSave = false; break; } } testFileResult.EndTime = DateTime.UtcNow; testFileResult.TotalRunTime = testFileResult.EndTime - testFileResult.StartTime; testFileResult.TotalTestsRun = totalTestsRun; testFileResult.MinResponseTime = minResponseTime; testFileResult.MaxResponseTime = maxResponseTime; if (shouldSave) { using (ITestFileResultRepository repository = RepositoryFactory.GetRepository()) { await repository.Add(testFileResult); } } NotifySubscribersOfCompletion(testFileResult.Id); return(testFileResult); }
public AdminController(ITestFileResultRepository testFileResultRepository) { _testFileResultRepository = testFileResultRepository; }