void RunTestsInAssembly(List <IDisposable> toDispose, AssemblyRunInfo runInfo) { if (cancelled) { return; } var assemblyFileName = runInfo.AssemblyFileName; var longRunningSeconds = runInfo.Configuration.LongRunningTestSecondsOrDefault; var controller = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName); lock (toDispose) toDispose.Add(controller); var xunitTestCases = runInfo.TestCases .Select(tc => new { vm = tc, tc = tc.TestCase }) .Where(tc => tc.tc.UniqueID != null) .ToDictionary(tc => tc.tc, tc => tc.vm); var executionOptions = TestFrameworkOptions.ForExecution(runInfo.Configuration); var diagSink = new DiagnosticMessageSink(d => context.Post(_ => OnDiagnosticMessage?.Invoke(d), null), runInfo.AssemblyFileName, executionOptions.GetDiagnosticMessagesOrDefault()); var deviceExecSink = new DeviceExecutionSink(xunitTestCases, this, context); IExecutionSink resultsSink = new DelegatingExecutionSummarySink(deviceExecSink, () => cancelled); if (longRunningSeconds > 0) { resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagSink); } var assm = new XunitProjectAssembly() { AssemblyFilename = runInfo.AssemblyFileName }; deviceExecSink.OnMessage(new TestAssemblyExecutionStarting(assm, executionOptions)); controller.RunTests(xunitTestCases.Select(tc => tc.Value.TestCase).ToList(), resultsSink, executionOptions); resultsSink.Finished.WaitOne(); deviceExecSink.OnMessage(new TestAssemblyExecutionFinished(assm, executionOptions, resultsSink.ExecutionSummary)); }
ManualResetEvent RunTestsInAssemblyAsync(List <IDisposable> toDispose, AssemblyRunInfo runInfo) { var @event = new ManualResetEvent(false); void Handler() { try { RunTestsInAssembly(toDispose, runInfo); } finally { @event.Set(); } } RunAsync(Handler); return(@event); }