public Task <RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { TestTraceListener.Ensure(); MessageBusOverride messageBusOverride = new MessageBusOverride(messageBus) .AddAfterStartingBeforeFinished(new ExecuteBeforeAfterAttributesMessageBusInjection(Method, _testCase.TestMethod.TestClass.Class)); var testInformationFixtureIndex = Array.IndexOf(constructorArguments, ClassRunner.TestMethodFixtureDummy); if (testInformationFixtureIndex == -1) { return(RunAsyncOverride(diagnosticMessageSink, messageBusOverride, constructorArguments, aggregator, cancellationTokenSource)); } var testMethodFixture = new TestMethodFixture(_testCase.TestMethod.Method.ToRuntimeMethod()); var constructorArgumentsCopy = InjectTestMethodFixture(constructorArguments, testInformationFixtureIndex, testMethodFixture); var testCaseRunTask = RunAsyncOverride(diagnosticMessageSink, messageBusOverride, constructorArgumentsCopy, aggregator, cancellationTokenSource); var observeTask = CreateObserveTask(testMethodFixture.FailedObservedTask, messageBusOverride, cancellationTokenSource); return(Task.WhenAny(testCaseRunTask, observeTask) .Unwrap() .ContinueWith((t, s) => { ((IDisposable)s).Dispose(); return t.Result; }, testMethodFixture, CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default)); }
public override Task <RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { TestTraceListener.Ensure(); MessageBusOverride messageBusOverride = new MessageBusOverride(messageBus) .AddAfterStartingBeforeFinished(new ExecuteBeforeAfterAttributesMessageBusInjection(Method, TestMethod.TestClass.Class)); var testMethodArguments = GetTestMethodArguments(); var runner = new TestCaseRunner(this, DisplayName, SkipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource); if (ThreadType == ThreadType.UI) { return(UIThreadHelper.Instance.Invoke(runner.RunAsync)); } messageBusOverride.AddAfterStartingBeforeFinished(new VerifyGlobalProviderMessageBusInjection()); return(ThreadType == ThreadType.Background ? Task.Run(() => runner.RunAsync()) : runner.RunAsync()); }
public override Task <RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { TestTraceListener.Ensure(); var testMethodArguments = GetTestMethodArguments(); var runner = new TestCaseRunner(this, DisplayName, SkipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource); switch (ThreadType) { case ThreadType.UI: return(MainThreadFixture.Invoke(runner.RunAsync)); case ThreadType.Background: return(Task.Run(() => runner.RunAsync())); default: return(runner.RunAsync()); } }