public void SetsDebugPort() { var lang = "test"; var extension = ".test"; var defaultWorkerPath = "./test"; var workerPath = "/path/to/custom/worker"; var config = new ConfigurationBuilder() .AddInMemoryCollection(new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>($"workers:{lang}:debug", "1000"), new KeyValuePair <string, string>($"workers:{lang}:path", workerPath), }) .Build(); var logger = new TestLogger("test"); var workerConfigFactory = new WorkerConfigFactory(config, logger); var workerConfigs = workerConfigFactory.GetConfigs(new List <IWorkerProvider>() { new TestWorkerProvider() { Language = lang, Extension = extension, DefaultWorkerPath = defaultWorkerPath } }); Assert.Equal(workerConfigs.Single().Arguments.WorkerPath, workerPath); }
private IEnumerable <WorkerConfig> TestReadWorkerProviderFromConfig(IEnumerable <TestLanguageWorkerConfig> configs, ILogger testLogger, string language = null, Dictionary <string, string> keyValuePairs = null, bool appSvcEnv = false) { Mock <IEnvironment> mockEnvironment = new Mock <IEnvironment>(); var workerPathSection = $"{LanguageWorkerConstants.LanguageWorkersSectionName}:{OutOfProcConstants.WorkersDirectorySectionName}"; try { foreach (var workerConfig in configs) { WorkerConfigTestUtilities.CreateWorkerFolder(rootPath, workerConfig); } IConfigurationRoot config = TestConfigBuilder(workerPathSection, keyValuePairs); var scriptHostOptions = new ScriptJobHostOptions(); var scriptSettingsManager = new ScriptSettingsManager(config); var configFactory = new WorkerConfigFactory(config, testLogger, _testSysRuntimeInfo, _testEnvironment); if (appSvcEnv) { var testEnvVariables = new Dictionary <string, string> { { EnvironmentSettingNames.AzureWebsiteInstanceId, "123" }, }; using (var variables = new TestScopedSettings(scriptSettingsManager, testEnvVariables)) { configFactory.BuildWorkerProviderDictionary(); return(configFactory.GetConfigs()); } } configFactory.BuildWorkerProviderDictionary(); return(configFactory.GetConfigs()); } finally { WorkerConfigTestUtilities.DeleteTestDir(rootPath); WorkerConfigTestUtilities.DeleteTestDir(customRootPath); } }