Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var settings = Configuration.GetSection("AzureBlobStorage").Get <AzureBlobStorageSettings>();

            services.AddSingleton <IAzureBlobStorageSettings>(settings);

            services.AddTransient(x => AzureBlobContainerClientFactory.Create(settings));

            services.AddCustomHealthChecks(settings);

            services.AddTransient <IDocumentRepository, AzureBlobDocumentRepository>();
            services.AddControllers();
            services.AddSwaggerGen(options =>
                                   options.SwaggerDoc("v1",
                                                      new OpenApiInfo
            {
                Title       = "Documents API",
                Version     = "v1",
                Description = "NHS Digital GP IT Buying Catalogue Documents HTTP API"
            }));
        }
        public void Create_NullRetryOptions_ReturnsContainerClient()
        {
            const string accountName      = "devstoreaccount1";
            const string containerName    = "Container";
            const string uri              = "http://127.0.0.1:10000/" + accountName;
            const string connectionString =
                "DefaultEndpointsProtocol=http;AccountName="
                + accountName + "UnitTest;AccountKey=;BlobEndpoint="
                + uri;

            var settings = new AzureBlobStorageSettings
            {
                ConnectionString = connectionString,
                ContainerName    = containerName,
            };

            var client = AzureBlobContainerClientFactory.Create(settings);

            client.Should().NotBeNull();
            client.AccountName.Should().Be(accountName);
            client.Name.Should().Be(containerName);
        }