internal void AddProvider(string workerDir)
        {
            try
            {
                Dictionary <string, WorkerDescription> descriptionProfiles = new Dictionary <string, WorkerDescription>();
                string workerConfigPath = Path.Combine(workerDir, LanguageWorkerConstants.WorkerConfigFileName);
                if (!File.Exists(workerConfigPath))
                {
                    _logger.LogDebug($"Did not find worker config file at: {workerConfigPath}");
                    return;
                }
                _logger.LogDebug($"Found worker config: {workerConfigPath}");
                string            json              = File.ReadAllText(workerConfigPath);
                JObject           workerConfig      = JObject.Parse(json);
                WorkerDescription workerDescription = workerConfig.Property(LanguageWorkerConstants.WorkerDescription).Value.ToObject <WorkerDescription>();
                workerDescription.WorkerDirectory = workerDir;
                var languageSection = _config.GetSection($"{LanguageWorkerConstants.LanguageWorkersSectionName}:{workerDescription.Language}");
                workerDescription.Arguments = workerDescription.Arguments ?? new List <string>();

                descriptionProfiles = GetWorkerDescriptionProfiles(workerConfig);
                if (ScriptSettingsManager.Instance.IsAppServiceEnvironment)
                {
                    // Overwrite default Description with AppServiceEnv profile
                    // TODO:pgopa delete after ANT78
                    workerDescription = GetWorkerDescriptionFromProfiles(LanguageWorkerConstants.WorkerDescriptionAppServiceEnvProfileName, descriptionProfiles, workerDescription);
                }

                GetDefaultExecutablePathFromAppSettings(workerDescription, languageSection);
                AddArgumentsFromAppSettings(workerDescription, languageSection);

                string workerPath = workerDescription.GetWorkerPath();
                if (string.IsNullOrEmpty(workerPath) || File.Exists(workerPath))
                {
                    _logger.LogDebug($"Will load worker provider for language: {workerDescription.Language}");
                    workerDescription.Validate();
                    _workerProviderDictionary[workerDescription.Language] = new GenericWorkerProvider(workerDescription, workerDir);
                }
                else
                {
                    throw new FileNotFoundException($"Did not find worker for for language: {workerDescription.Language}", workerPath);
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex, $"Failed to initialize worker provider for: {workerDir}");
            }
        }
 public void ValidateWorkerDescription_Succeeds(WorkerDescription workerDescription)
 {
     workerDescription.Validate();
 }
 public void InvalidWorkerDescription_Throws(WorkerDescription workerDescription)
 {
     Assert.Throws <ValidationException>(() => workerDescription.Validate());
 }