Esempio n. 1
0
        public TestModel(NUnit.Engine.ITestEngine testEngine, string applicationPrefix = null)
        {
            TestEngine       = testEngine;
            _settingsService = new SettingsService(true);
            _events          = new TestEventDispatcher(this);
            _assemblyWatcher = new AssemblyWatcher();

            _settingsService.LoadSettings();
            Settings    = new UserSettings(_settingsService, applicationPrefix);
            RecentFiles = new RecentFiles(_settingsService, applicationPrefix);

            Services = new TestServices(testEngine);

            AvailableAgents = new List <string>(
                Services.TestAgentService.GetAvailableAgents().Select((a) => a.AgentName));

            foreach (var node in Services.ExtensionService.GetExtensionNodes(PROJECT_LOADER_EXTENSION_PATH))
            {
                if (node.TypeName == NUNIT_PROJECT_LOADER)
                {
                    NUnitProjectSupport = true;
                }
                else if (node.TypeName == VISUAL_STUDIO_PROJECT_LOADER)
                {
                    VisualStudioSupport = true;
                }
            }
        }
Esempio n. 2
0
        // Public for testing
        public static ITestModel CreateTestModel(NUnit.Engine.ITestEngine testEngine, CommandLineOptions options)
        {
            // Currently the InternalTraceLevel can only be set from the command-line.
            // We can't use user settings to provide a default because the settings
            // are an engine service and the engine have the internal trace level
            // set as part of its initialization.
            var traceLevel = options.InternalTraceLevel != null
                ? (NUnit.Engine.InternalTraceLevel)Enum.Parse(typeof(NUnit.Engine.InternalTraceLevel), options.InternalTraceLevel)
                : NUnit.Engine.InternalTraceLevel.Off;

            // This initializes the trace setting for the process.
            InternalTrace.Initialize($"InternalTrace.{Process.GetCurrentProcess().Id}.gui.log", traceLevel);

            testEngine.InternalTraceLevel = traceLevel;
            if (options.WorkDirectory != null)
            {
                testEngine.WorkDirectory = options.WorkDirectory;
            }

            var model = new TestModel(testEngine, "TestCentric");


            model.PackageOverrides.Add(EnginePackageSettings.InternalTraceLevel, testEngine.InternalTraceLevel.ToString());

            if (options.MaxAgents >= 0)
            {
                model.PackageOverrides.Add(EnginePackageSettings.MaxAgents, options.MaxAgents);
            }
            if (options.RunAsX86)
            {
                model.PackageOverrides.Add(EnginePackageSettings.RunAsX86, true);
            }
            if (options.DebugAgent)
            {
                model.PackageOverrides.Add(EnginePackageSettings.DebugAgent, true);
            }
            if (options.SimulateUnloadError)
            {
                model.PackageOverrides.Add(EnginePackageSettings.SimulateUnloadError, true);
            }
            if (options.SimulateUnloadTimeout)
            {
                model.PackageOverrides.Add(EnginePackageSettings.SimulateUnloadTimeout, true);
            }

            return(model);
        }