Exemplo n.º 1
0
        public async Task PrepareForRun(IUnitTestRun run)
        {
            // ToDo Replace this LifetimeDefinition with LifetimeDefinition from PrepareForRun (When it will be updated. It need to cancel PrepareForRun)
            var lifetimeDef = new LifetimeDefinition();

            await myInnerHostController.PrepareForRun(run).ConfigureAwait(false);

            if (!myUnityController.IsUnityEditorUnitTestRunStrategy(run.RunStrategy))
            {
                return;
            }

            lock (myStartUnitySync)
            {
                myStartUnityTask = myStartUnityTask.ContinueWith(_ =>
                {
                    var unityEditorProcessId = myUnityController.TryGetUnityProcessId();
                    return(unityEditorProcessId.HasValue
                        ? Task.CompletedTask
                        : myShellLocks.Tasks.StartNew(lifetimeDef.Lifetime, Scheduling.FreeThreaded, StartUnityIfNeed));
                }, lifetimeDef.Lifetime, TaskContinuationOptions.None, myShellLocks.Tasks.GuardedMainThreadScheduler).Unwrap();
            }

            await myStartUnityTask.ConfigureAwait(false);
        }
        private async Task PrepareForRunInternal(Lifetime lifetime, IUnitTestRun run)
        {
            var unityEditorProcessId = myUnityController.TryGetUnityProcessId();

            if (unityEditorProcessId.HasValue)
            {
                return;
            }

            var message = string.Format(StartUnityEditorQuestionMessage,
                                        myAvailableProviders[run.HostController.HostId],
                                        myUnityController.GetPresentableUnityVersion());

            if (!MessageBox.ShowYesNo(message, PluginName))
            {
                throw new Exception(string.Format(NotAvailableUnityEditorMessage, myAvailableProviders[run.HostController.HostId]));
            }

            var startUnityTask = StartUnity(lifetime);

            await myShellLocks.Tasks.YieldToIfNeeded(lifetime, Scheduling.MainGuard);

            ShowProgress(lifetime, startUnityTask);

            await startUnityTask.ConfigureAwait(false);
        }
        public async Task PrepareForRun(IUnitTestRun run)
        {
            var lifetimeDef = Lifetime.Define();

            run.PutData(ourLifetimeDefinitionKey, lifetimeDef);

            await myInnerHostController.PrepareForRun(run).ConfigureAwait(false);

            if (!myUnityController.IsUnityEditorUnitTestRunStrategy(run.RunStrategy))
            {
                return;
            }

            lock (myStartUnitySync)
            {
                myStartUnityTask = myStartUnityTask.ContinueWith(_ =>
                {
                    var unityEditorProcessId = myUnityController.TryGetUnityProcessId();
                    return(unityEditorProcessId.HasValue
                        ? Task.CompletedTask
                        : myShellLocks.Tasks.StartNew(lifetimeDef.Lifetime, Scheduling.FreeThreaded, () => StartUnityIfNeed(lifetimeDef.Lifetime)));
                }, lifetimeDef.Lifetime, TaskContinuationOptions.None, myShellLocks.Tasks.GuardedMainThreadScheduler).Unwrap();
            }

            await myStartUnityTask.ConfigureAwait(false);
        }