Small refactoring.

pull/4200/head
maliming 5 years ago
parent 0e2e5629aa
commit 3acc5c8c85

@ -2,9 +2,7 @@
namespace Volo.Abp.BlobStoring.Azure
{
[DependsOn(
typeof(AbpBlobStoringModule)
)]
[DependsOn(typeof(AbpBlobStoringModule))]
public class AbpBlobStoringAzureModule : AbpModule
{

@ -45,7 +45,6 @@ namespace Volo.Abp.BlobStoring.Azure
}
var download = await blobClient.DownloadAsync();
var memoryStream = new MemoryStream();
await download.Value.Content.CopyToAsync(memoryStream);
return memoryStream;
@ -65,8 +64,7 @@ namespace Volo.Abp.BlobStoring.Azure
private static async Task<bool> BlobExistsAsync(BlobClient blobClient)
{
var response = await blobClient.ExistsAsync();
return response.Value;
return (await blobClient.ExistsAsync()).Value;
}
}
}

@ -12,7 +12,9 @@ namespace Volo.Abp.BlobStoring.Azure
)]
public class AbpBlobStoringAzureTestModule : AbpModule
{
public static string UserSecretsId = "9f0d2c00-80c1-435b-bfab-2c39c8249091";
private const string UserSecretsId = "9f0d2c00-80c1-435b-bfab-2c39c8249091";
private string _connectionString;
private readonly string _randomContainerName = "abp-azure-test-container-" + Guid.NewGuid().ToString("N");
@ -25,7 +27,9 @@ namespace Volo.Abp.BlobStoring.Azure
var configuration = context.Services.GetConfiguration();
var blobServiceClient = new BlobServiceClient(configuration["Azure:ConnectionString"]);
_connectionString = configuration["Azure:ConnectionString"];
var blobServiceClient = new BlobServiceClient(_connectionString);
blobServiceClient.CreateBlobContainer(_randomContainerName);
Configure<AbpBlobStoringOptions>(options =>
@ -34,7 +38,7 @@ namespace Volo.Abp.BlobStoring.Azure
{
containerConfiguration.UseAzure(azure =>
{
azure.ConnectionString = configuration["Azure:ConnectionString"];
azure.ConnectionString = _connectionString;
azure.ContainerName = _randomContainerName;
});
});
@ -44,7 +48,7 @@ namespace Volo.Abp.BlobStoring.Azure
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
var blobServiceClient = new BlobServiceClient(configuration["Azure:ConnectionString"]);
var blobServiceClient = new BlobServiceClient(_connectionString);
blobServiceClient.DeleteBlobContainer(_randomContainerName);
}
}

@ -1,9 +1,10 @@
using Xunit;
//#define I_HAVE_SET_THE_CORRECT_CONNECTIONSTRING_IN_THE_USERSECRETS_FILE
namespace Volo.Abp.BlobStoring.Azure
{
#if I_HAVE_SET_THE_CORRECT_CONNECTION_STRING_IN_THE_USERSECRETS_FILE
/*
//Please set the correct connection string in secrets.json and continue the test.
public class AzureBlobContainer_Tests : BlobContainer_Tests<AbpBlobStoringAzureTestModule>
{
public AzureBlobContainer_Tests()
@ -11,5 +12,5 @@ namespace Volo.Abp.BlobStoring.Azure
}
}
#endif
*/
}

Loading…
Cancel
Save