public void GetWithReplacementArgumentTest() { Assert.Throws <ArgumentNullException>("configuration", () => IConfigurationExtensions.GetWithReplacement(null, null)); IConfigurationBuilder configuration = new ConfigurationBuilder(); IConfiguration config = configuration.Build(); Assert.Throws <ArgumentNullException>("key", () => config.GetWithReplacement(null)); }
public virtual TClient Create(string name, IConfiguration configuration) { if (string.IsNullOrWhiteSpace(name)) { name = ConnectionStringNames.Storage; // default } IConfigurationSection connectionSection = configuration?.GetWebJobsConnectionSection(name); if (connectionSection == null || !connectionSection.Exists()) { // Not found throw new InvalidOperationException($"Storage account connection string '{IConfigurationExtensions.GetPrefixedConnectionStringName(name)}' does not exist. Make sure that it is a defined App Setting."); } var credential = _componentFactory.CreateTokenCredential(connectionSection); var options = CreateClientOptions(connectionSection); return(CreateClient(connectionSection, credential, options)); }
public void GetLambdaLoggerOptions_Should_Throw_When_Config_Is_Null_Test() { Assert.Throws <ArgumentNullException>(() => IConfigurationExtensions.GetLambdaLoggerOptions(null)); }
public async Task <IBinding> TryCreateAsync(BindingProviderContext context) { var parameter = context.Parameter; var parameterName = context.Parameter.Name; var parameterType = context.Parameter.ParameterType; var attribute = parameter.GetCustomAttribute <GenesysAttribute>(); if (attribute == null) { return(null); } if (parameterType != typeof(string) && parameterType != typeof(IGenesysAccessToken)) { throw new InvalidOperationException("Can't bind entity to type '" + parameterType + "'."); } var connectionString = GetConnectionString(attribute.Connection); if (!TableStorageAccount.TryParse(connectionString, out TableStorageAccount tableStorageAccount)) { throw new InvalidOperationException($"Storage account connection string for '{IConfigurationExtensions.GetPrefixedConnectionStringName(attribute.Connection)}' is invalid"); } var tableClient = tableStorageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference(attribute.TokenTable ?? GenesysConfigNames.GenesysTokensTable); await table.CreateIfNotExistsAsync(); var tokenCtx = new GenesysTokenContext { TokenTable = table, ClientId = attribute.ClientId, ClientSecret = attribute.ClientSecret, Environment = attribute.Environment, }; IBinding binding = new GenesysAttributeBinding(parameterName, parameterType, _tokenProvider, tokenCtx); return(binding); }