public void GetSettingFromConfigOrEnvironment_ConfigSetting_NoEnvironmentSetting() { ConfigurationUtility.Reset(); string value = ConfigurationUtility.GetSetting("DisableSetting0"); Assert.Equal("0", value); }
public void GetSettingFromConfigOrEnvironment_NameNull_ReturnsEmpty() { ConfigurationUtility.Reset(); string value = ConfigurationUtility.GetSetting(null); Assert.Equal(null, value); }
public void GetSettingFromConfigOrEnvironment_ConfigAndEnvironment_EnvironmentWins() { Environment.SetEnvironmentVariable("DisableSetting0", "1"); string value = ConfigurationUtility.GetSetting("DisableSetting0"); Assert.Equal("1", value); Environment.SetEnvironmentVariable("DisableSetting0", null); }
public void GetSettingFromConfigOrEnvironment_EnvironmentSetting_NoConfigSetting() { Environment.SetEnvironmentVariable("EnvironmentSetting", "1"); string value = ConfigurationUtility.GetSetting("EnvironmentSetting"); Assert.Equal("1", value); Environment.SetEnvironmentVariable("EnvironmentSetting", null); }
/// <summary> /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the /// specified connection string for both reading and writing data as well as Dashboard logging. /// </summary> /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use. /// <param name="configuration">A configuration object that will be used as the source of application settings.</param> /// </param> public JobHostConfiguration(string dashboardAndStorageConnectionString, IConfiguration configuration) { if (configuration != null) { ConfigurationUtility.SetConfigurationFactory(() => configuration); } if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString)) { _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString); } else { _storageAccountProvider = new DefaultStorageAccountProvider(this); } var sasBlobContainer = _storageAccountProvider.InternalSasStorage; if (sasBlobContainer != null) { var uri = new Uri(sasBlobContainer); var sdkContainer = new CloudBlobContainer(uri); this.InternalStorageConfiguration = new JobHostInternalStorageConfiguration { InternalContainer = sdkContainer }; } Singleton = new SingletonConfiguration(); Aggregator = new FunctionResultAggregatorConfiguration(); // add our built in services here IExtensionRegistry extensions = new DefaultExtensionRegistry(); ITypeLocator typeLocator = new DefaultTypeLocator(ConsoleProvider.Out, extensions); IConverterManager converterManager = new ConverterManager(); IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler(); AddService <IQueueConfiguration>(_queueConfiguration); AddService <IConsoleProvider>(ConsoleProvider); AddService <ILoggerFactory>(new LoggerFactory()); AddService <IStorageAccountProvider>(_storageAccountProvider); AddService <IExtensionRegistry>(extensions); AddService <StorageClientFactory>(new StorageClientFactory()); AddService <INameResolver>(new DefaultNameResolver()); AddService <IJobActivator>(DefaultJobActivator.Instance); AddService <ITypeLocator>(typeLocator); AddService <IConverterManager>(converterManager); AddService <IWebJobsExceptionHandler>(exceptionHandler); AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory()); string value = ConfigurationUtility.GetSetting(Host.Constants.EnvironmentSettingName); IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0; }
public void GetSetting_NormalizesKeys(string key, string lookup) { try { string value = Guid.NewGuid().ToString(); Environment.SetEnvironmentVariable(key, value); string result = ConfigurationUtility.GetSetting(lookup); Assert.Equal(value, result); } finally { Environment.SetEnvironmentVariable(key, null); } }
/// <summary> /// Resolves tokens by looking first in App Settings and then in environment variables. /// </summary> /// <param name="name">The token to resolve.</param> /// <returns>The token value from App Settings or environment variables. If the token is not found, null is returned.</returns> public virtual string Resolve(string name) { return(ConfigurationUtility.GetSetting(name)); }
public void GetSettingFromConfigOrEnvironment_NotFound_ReturnsEmpty() { string value = ConfigurationUtility.GetSetting("DNE"); Assert.Equal(null, value); }