Exemplo n.º 1
0
        private async Task <RunSummary> Remote_RunTestCasesAsync(string instanceId, IEnumerable <VsTestCaseBase> testCases, IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
        {
            if (testCases.All(tc => !string.IsNullOrEmpty(tc.SkipReason)))
            {
                return(await Local_RunTestCasesAsync(testCases, messageBus, cancellationTokenSource));
            }

            var instanceTestCase = TestCases.OfType <VsInstanceTestCase>().FirstOrDefault(tc => tc.InstanceId == instanceId);

            return(await ThreadUtil.RunOnStaThreadAsync(async() =>
            {
                var runner = new VsInstanceTestAssemblyRunner(TestAssembly, testCases, instanceTestCase, DiagnosticMessageSink, ExecutionMessageSink, ExecutionOptions, () => CreateMessageBus(), Aggregator);

                try
                {
                    using (var retryFilter = new RetryMessageFilter())
                    {
                        return await runner.RunAsync(cancellationTokenSource);
                    }
                }
                finally
                {
                    await runner.DisposeAsync();
                }
            }));
        }
Exemplo n.º 2
0
 public async Task RunOnStaThreadAsync()
 {
     Assert.Equal(1520, await ThreadUtil.RunOnStaThreadAsync(async() =>
     {
         Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
         var id = Thread.CurrentThread.ManagedThreadId;
         await Task.Yield();
         Assert.Equal(ApartmentState.STA, Thread.CurrentThread.GetApartmentState());
         Assert.Equal(Thread.CurrentThread.ManagedThreadId, id);
         return(1520);
     }));
 }
Exemplo n.º 3
0
 public async Task LaunchAndDebug(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource)
 {
     await ThreadUtil.RunOnStaThreadAsync(async() =>
     {
         using (var retryFilter = new RetryMessageFilter())
         {
             var diagnostics         = new VisualDiagnostics(this, DiagnosticMessageSink, messageBus, cancellationTokenSource);
             var extensionsToInstall = VsInstance.GetExtensionsToInstall(ExtensionDirectories);
             var installation        = VisualStudioUtil.FindInstallations().First(i => i.ApplicationPath == ApplicationPath);
             var hive = new VsHive(installation, RootSuffix);
             await VsInstance.Prepare(hive, extensionsToInstall, resetSettings: false, diagnostics, installInvoker: false);
             var process = await diagnostics.RunAsync("Launching Instance", () => Task.FromResult(VisualStudioUtil.StartProcess(hive)));
             if (Debugger.IsAttached)
             {
                 await VsInstance.AttachDebugger(process, DebugMixedMode, diagnostics);
             }
         }
     });
 }