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 = constructorArguments.Any(a => a is IMethodFixture) ? new TestCaseRunnerWithMethodFixtures(this, DisplayName, SkipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource) : 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 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); }
protected abstract Task<RunSummary> RunAsyncOverride(IMessageSink diagnosticMessageSink, MessageBusOverride messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource);
protected override Task<RunSummary> RunAsyncOverride(IMessageSink diagnosticMessageSink, MessageBusOverride messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { return UIThreadHelper.Instance.Invoke(() => TestCase.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource)); }
protected override Task<RunSummary> RunAsyncOverride(IMessageSink diagnosticMessageSink, MessageBusOverride messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) { messageBus.AddAfterStartingBeforeFinished(new VerifyGlobalProviderMessageBusInjection()); return TestCase.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource); }