Ejemplo 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);
        }
        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);
        }
        public bool IsApplicable(IUnitTestRun run)
        {
            var isUnity = myUnityController.IsUnityEditorUnitTestRunStrategy(run.RunStrategy);

            return(isUnity && myAvailableProviders.ContainsKey(run.HostController.HostId));
        }