private async Task <RunSummary> RunIsolatedAsync() { IsolatedContext isolatedContext = null; TestCollectionScope scope; try { isolatedContext = new IsolatedContext(_appDomainFixtureTypes, Aggregator); scope = new TestCollectionScope(TestCollection, _meeMessageSinkWithEvents, isolatedContext, _dispositionTaskFactory, DiagnosticMessageSink); // owns the isolated instance } catch (Exception) { isolatedContext?.Dispose(); throw; } try { var remoteTestCases = isolatedContext.CreateRemoteTestCases(TestCases, _testCaseDeserializerArgs); var remoteCancellationTokenSource = isolatedContext.CreateRemoteCancellationTokenSource(CancellationTokenSource); var runnerArgs = new object[] { TestCollection, remoteTestCases, DiagnosticMessageSink, MessageBus, TestCaseOrderer.GetType(), remoteCancellationTokenSource, Aggregator.ToException() }; var runSummary = await isolatedContext.CreateRemoteInstanceAndRunAsync <RemoteTestCollectionRunner>(runnerArgs, RemoteTestCollectionRunner.MethodRunAsync); // now that the run summary is available schedule the disposition of the scope as soon as it is completed scope.DisposeOnCompletionAsync(CancellationTokenSource.Token); return(runSummary); } catch (Exception) { scope.Dispose(); throw; } }
protected IsolationScope(IsolatedContext isolatedContext, TaskFactory dispositionTaskFactory, IMessageSink diagnosticMessageSink) { _isolatedContext = isolatedContext; _dispositionTaskFactory = dispositionTaskFactory; _diagnosticMessageSink = diagnosticMessageSink; }
public TestCollectionScope(ITestCollection testCollection, IMessageSinkWithEvents messageSinkWithEvents, IsolatedContext isolatedContext, TaskFactory dispositionTaskFactory, IMessageSink diagnosticMessageSink) : base(isolatedContext, dispositionTaskFactory, diagnosticMessageSink) { _testCollection = testCollection; _messageSinkWithEvents = messageSinkWithEvents; _messageSinkWithEvents.TestCollectionFinished += MessageSinkWithEventsOnTestCollectionFinished; }