private void AddTestJobImpl(ITestJobManager testJobManager, ICollection <WorkItem> workItems) { TestcaseProvider testcaseProvider; object branchSpecificFileLock = _testFileLocker.GetLock(testJobManager.TestJob.Testsystem.Name); lock (branchSpecificFileLock) { testcaseProvider = new TestcaseProvider(RegtestingServerConfiguration.Testsfolder + testJobManager.TestJob.Testsystem.Filename); testcaseProvider.CreateAppDomain(); } _testJobRepository.Store(testJobManager.TestJob); lock (_lockWorkItems) { List <WorkItem> alreadyFoundWorkItems = new List <WorkItem>(); List <Result> updatedResults = new List <Result>(); foreach (WorkItem workItem in workItems) { ITestable testable = GetTestable(workItem, testcaseProvider); if (testable == null) { updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.NotAvailable)); continue; } if (!IsWorkItemSupported(workItem, testable)) { updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.NotSupported)); continue; } WorkItem existingWorkItem = CheckForAlreadyQueyedWorkItems(workItem); if (existingWorkItem != null) { existingWorkItem.AddTestJobManager(testJobManager); alreadyFoundWorkItems.Add(existingWorkItem); } else { testJobManager.AddWorkItem(workItem); updatedResults.Add(UpdateResultInfos(workItem, testJobManager.TestJob, TestState.Pending)); } } //If there is nothing to test, don't add a testsuite if (testJobManager.Count == 0 && alreadyFoundWorkItems.Count == 0) { return; } _currentTestJobManagers.Add(testJobManager); //Add new workItems to waiting list testJobManager.WorkItems.ForEach(_waitingWorkItems.Add); //Add already found workItems back to alreadyFoundWorkItems.ForEach(testJobManager.AddWorkItem); _resultRepository.Store(updatedResults); } }