public AppDomainEngineInvoker(string testSourcePath)
        {
            TestPlatformEventSource.Instance.TestHostAppDomainCreationStart();

            this.appDomain     = CreateNewAppDomain(testSourcePath);
            this.actualInvoker = CreateInvokerInAppDomain(appDomain);

            TestPlatformEventSource.Instance.TestHostAppDomainCreationStop();
        }
示例#2
0
        public AppDomainEngineInvoker(string testSourcePath, AppDomainInitializer initializer = null, string appBasePath = null)
        {
            TestPlatformEventSource.Instance.TestHostAppDomainCreationStart();

            this.appDomain = CreateNewAppDomain(testSourcePath, initializer, appBasePath);

            // Setting appbase later, as AppDomain needs to load testhost.exe into the new Domain, to have access to AppDomainInitializer method.
            // If we set appbase to testsource folder, then if fails to find testhost.exe resulting in FileNotFoundException for testhost.exe
            this.UpdateAppBaseToTestSourceLocation(testSourcePath);
            this.actualInvoker = CreateInvokerInAppDomain(appDomain);

            TestPlatformEventSource.Instance.TestHostAppDomainCreationStop();
        }
示例#3
0
        private static IEngineInvoker GetEngineInvoker(IDictionary <string, string> argsDictionary)
        {
            IEngineInvoker invoker = null;

#if NETFRAMEWORK
            // If Args contains test source argument, invoker Engine in new appdomain
            if (argsDictionary.TryGetValue(TestSourceArgumentString, out var testSourcePath) && !string.IsNullOrWhiteSpace(testSourcePath))
            {
                // remove the test source arg from dictionary
                argsDictionary.Remove(TestSourceArgumentString);

                // Only DLLs and EXEs can have app.configs or ".exe.config" or ".dll.config"
                if (System.IO.File.Exists(testSourcePath) &&
                    (testSourcePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
                     testSourcePath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)))
                {
                    invoker = new AppDomainEngineInvoker <DefaultEngineInvoker>(testSourcePath);
                }
            }
#endif
            return(invoker ?? new DefaultEngineInvoker());
        }