public TestFixture() { var configurationBuilder = new ConfigurationBuilder(); ConfigurationRoot = configurationBuilder .AddEnvironmentVariables() .AddJsonFile("appsettings.json", false, true) .Build(); var azureServicesAuthConnectionString = ConfigurationRoot.GetValue <string>("AzureServicesAuthConnectionString"); var azureServiceTokenProvider = new AzureServiceTokenProvider(); var keyVaultClient = new KeyVaultClient( new KeyVaultClient.AuthenticationCallback( azureServiceTokenProvider.KeyVaultTokenCallback)); ConfigurationRoot = configurationBuilder .AddAzureKeyVault( ConfigurationRoot[KeyVaultUrl], keyVaultClient, new DefaultKeyVaultSecretManager()) .Build(); var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(); serviceCollection.AddSingleton(provider => { var storageAccount = CloudStorageAccount.Parse(ConfigurationRoot.GetValue <string>(StorageAccountConnectionString)); var cloudBlobClient = storageAccount.CreateCloudBlobClient(); return(cloudBlobClient); }); serviceCollection.AddScoped <IBlobStorageClient, BlobStorageClient>(); serviceCollection.Configure <BlobStorageSettings>(options => { options.ContainerName = "startrekipsum"; options.ConnectionString = StorageAccountConnectionString; }); serviceCollection.AddTransient <IStarTrekIpsumGenerator, StarTrekIpsumGenerator>(); ServiceProvider = serviceCollection.BuildServiceProvider(); }
public T GetValue <T>(string name) { T value = ConfigurationRoot.GetValue <T>(name); return(value); }