コード例 #1
0
        private async Task <ITestRunner> GetTestRunnerWithoutExceptionHandlingAsync(string testClassId)
        {
            if (!testRunnerRegistry.TryGetValue(testClassId, out var testRunner))
            {
                await syncRootSemaphore.WaitAsync();

                try
                {
                    if (!testRunnerRegistry.TryGetValue(testClassId, out testRunner))
                    {
                        testRunner = await CreateTestRunnerAsync(testClassId);

                        testRunnerRegistry.Add(testClassId, testRunner);

                        if (IsMultiThreaded)
                        {
                            FeatureContext.DisableSingletonInstance();
                            ScenarioContext.DisableSingletonInstance();
                            ScenarioStepContext.DisableSingletonInstance();
                        }
                    }
                }
                finally
                {
                    syncRootSemaphore.Release();
                }
            }
            return(testRunner);
        }
コード例 #2
0
ファイル: TestRunnerManager.cs プロジェクト: sphinxy/SpecFlow
        private ITestRunner GetTestRunnerWithoutExceptionHandling(int threadId)
        {
            ITestRunner testRunner;

            if (!testRunnerRegistry.TryGetValue(threadId, out testRunner))
            {
                lock (syncRoot)
                {
                    if (!testRunnerRegistry.TryGetValue(threadId, out testRunner))
                    {
                        testRunner = CreateTestRunner(threadId);
                        testRunnerRegistry.Add(threadId, testRunner);

                        if (IsMultiThreaded)
                        {
                            FeatureContext.DisableSingletonInstance();
                            ScenarioContext.DisableSingletonInstance();
                            ScenarioStepContext.DisableSingletonInstance();
                        }
                    }
                }
            }
            return(testRunner);
        }