Skip to content

Commit 5419b80

Browse files
Test cleanup (Azure#38334)
* removed duplicate disposing container * moved generic test stream to common
1 parent 48384b7 commit 5419b80

18 files changed

+283
-306
lines changed

sdk/storage/Azure.Storage.Blobs/tests/FuncStream.cs renamed to sdk/storage/Azure.Storage.Common/tests/Shared/FuncStream.cs

File renamed without changes.

sdk/storage/Azure.Storage.DataMovement/tests/AppendBlobStorageResourceTests.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Azure.Storage.Blobs;
1313
using Azure.Storage.Blobs.Models;
1414
using Azure.Storage.Blobs.Specialized;
15+
using Azure.Storage.Blobs.Tests;
1516
using Azure.Storage.DataMovement.Tests;
1617
using Azure.Storage.Test;
1718
using NUnit.Framework;
@@ -40,7 +41,7 @@ public void Ctor_PublicUri()
4041
public async Task ReadStreamAsync()
4142
{
4243
// Arrange
43-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
44+
await using DisposingContainer testContainer = await GetTestContainerAsync();
4445
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
4546
var length = Constants.KB;
4647
await blobClient.CreateAsync();
@@ -64,7 +65,7 @@ public async Task ReadStreamAsync()
6465
public async Task ReadStreamAsync_Position()
6566
{
6667
// Arrange
67-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
68+
await using DisposingContainer testContainer = await GetTestContainerAsync();
6869
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
6970

7071
int readPosition = 512;
@@ -93,7 +94,7 @@ public async Task ReadStreamAsync_Position()
9394
public async Task ReadStreamAsync_Error()
9495
{
9596
// Arrange
96-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
97+
await using DisposingContainer testContainer = await GetTestContainerAsync();
9798
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
9899
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
99100

@@ -110,7 +111,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
110111
public async Task ReadStreamAsync_Partial()
111112
{
112113
// Arrange
113-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
114+
await using DisposingContainer testContainer = await GetTestContainerAsync();
114115
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
115116
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
116117

@@ -135,7 +136,7 @@ public async Task ReadStreamAsync_Partial()
135136
public async Task WriteFromStreamAsync()
136137
{
137138
// Arrange
138-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
139+
await using DisposingContainer testContainer = await GetTestContainerAsync();
139140
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
140141

141142
var length = Constants.KB;
@@ -161,7 +162,7 @@ await storageResource.CopyFromStreamAsync(
161162
public async Task WriteFromStreamAsync_Position()
162163
{
163164
// Arrange
164-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
165+
await using DisposingContainer testContainer = await GetTestContainerAsync();
165166
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
166167

167168
long readPosition = Constants.KB;
@@ -202,7 +203,7 @@ await storageResource.CopyFromStreamAsync(
202203
public async Task WriteFromStreamAsync_Error()
203204
{
204205
// Arrange
205-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
206+
await using DisposingContainer testContainer = await GetTestContainerAsync();
206207
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
207208
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
208209

@@ -232,7 +233,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
232233
public async Task CopyFromUriAsync()
233234
{
234235
// Arrange
235-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
236+
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
236237
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
237238
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
238239

@@ -262,7 +263,7 @@ public async Task CopyFromUriAsync_OAuth()
262263
{
263264
// Arrange
264265
BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth();
265-
await using DisposingBlobContainer test = await GetTestContainerAsync(
266+
await using DisposingContainer test = await GetTestContainerAsync(
266267
service: serviceClient,
267268
publicAccessType: PublicAccessType.None);
268269

@@ -306,7 +307,7 @@ public async Task CopyFromUriAsync_HttpAuthorization()
306307
{
307308
// Arrange
308309
BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth();
309-
await using DisposingBlobContainer test = await GetTestContainerAsync(
310+
await using DisposingContainer test = await GetTestContainerAsync(
310311
service: serviceClient,
311312
publicAccessType: PublicAccessType.None);
312313

@@ -347,7 +348,7 @@ await destinationResource.CopyFromUriAsync(
347348
public async Task CopyFromUriAsync_Error()
348349
{
349350
// Arrange
350-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
351+
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
351352
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
352353
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
353354

@@ -368,7 +369,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
368369
public async Task CopyBlockFromUriAsync()
369370
{
370371
// Arrange
371-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
372+
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
372373
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
373374
await sourceClient.CreateIfNotExistsAsync();
374375
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
@@ -407,7 +408,7 @@ public async Task CopyBlockFromUriAsync_OAuth()
407408
{
408409
// Arrange
409410
BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth();
410-
await using DisposingBlobContainer test = await GetTestContainerAsync(
411+
await using DisposingContainer test = await GetTestContainerAsync(
411412
service: serviceClient,
412413
publicAccessType: PublicAccessType.None);
413414
AppendBlobClient sourceClient = test.Container.GetAppendBlobClient(GetNewBlobName());
@@ -454,7 +455,7 @@ await destinationResource.CopyBlockFromUriAsync(
454455
public async Task CopyBlockFromUriAsync_OAuth_Token()
455456
{
456457
// Arrange
457-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.None);
458+
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.None);
458459
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
459460
await sourceClient.CreateIfNotExistsAsync();
460461
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
@@ -504,7 +505,7 @@ public async Task CopyBlockFromUriAsync_HttpAuthorization()
504505
{
505506
// Arrange
506507
BlobServiceClient serviceClient = BlobsClientBuilder.GetServiceClient_OAuth();
507-
await using DisposingBlobContainer test = await GetTestContainerAsync(
508+
await using DisposingContainer test = await GetTestContainerAsync(
508509
service: serviceClient,
509510
publicAccessType: PublicAccessType.None);
510511
AppendBlobClient sourceClient = test.Container.GetAppendBlobClient(GetNewBlobName());
@@ -551,7 +552,7 @@ await destinationResource.CopyBlockFromUriAsync(
551552
public async Task CopyBlockFromUriAsync_Error()
552553
{
553554
// Arrange
554-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
555+
await using DisposingContainer testContainer = await GetTestContainerAsync(publicAccessType: PublicAccessType.BlobContainer);
555556
AppendBlobClient sourceClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
556557
AppendBlobClient destinationClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
557558

@@ -572,7 +573,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
572573
public async Task GetPropertiesAsync()
573574
{
574575
// Arrange
575-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
576+
await using DisposingContainer testContainer = await GetTestContainerAsync();
576577
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
577578

578579
var length = Constants.KB;
@@ -598,7 +599,7 @@ public async Task GetPropertiesAsync()
598599
public async Task GetPropertiesAsync_Error()
599600
{
600601
// Arrange
601-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
602+
await using DisposingContainer testContainer = await GetTestContainerAsync();
602603
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
603604

604605
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
@@ -616,7 +617,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
616617
public async Task CompleteTransferAsync()
617618
{
618619
// Arrange
619-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
620+
await using DisposingContainer testContainer = await GetTestContainerAsync();
620621
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
621622
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
622623

@@ -642,7 +643,7 @@ await storageResource.CopyFromStreamAsync(
642643
public async Task CompleteTransferAsync_Error()
643644
{
644645
// Arrange
645-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
646+
await using DisposingContainer testContainer = await GetTestContainerAsync();
646647
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
647648

648649
AppendBlobStorageResource storageResource = new AppendBlobStorageResource(blobClient);
@@ -660,7 +661,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
660661
public async Task GetCopyAuthorizationHeaderAsync()
661662
{
662663
// Arrange
663-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync();
664+
await using DisposingContainer testContainer = await GetTestContainerAsync();
664665
AppendBlobClient blobClient = testContainer.Container.GetAppendBlobClient(GetNewBlobName());
665666

666667
var length = Constants.KB;
@@ -686,7 +687,7 @@ public async Task GetCopyAuthorizationHeaderAsync_OAuth()
686687
// Arrange
687688
var containerName = GetNewContainerName();
688689
BlobServiceClient service = BlobsClientBuilder.GetServiceClient_OAuth();
689-
await using DisposingBlobContainer testContainer = await GetTestContainerAsync(
690+
await using DisposingContainer testContainer = await GetTestContainerAsync(
690691
service,
691692
containerName,
692693
publicAccessType: PublicAccessType.None);

sdk/storage/Azure.Storage.DataMovement/tests/Azure.Storage.DataMovement.Tests.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
<ItemGroup>
1616
<Compile Include="$(AzureCoreSharedSources)AppContextSwitchHelper.cs" LinkBase="Shared\Core" />
1717
<Compile Include="$(AzureCoreSharedSources)ContentTypeUtilities.cs" LinkBase="Shared\Core" />
18-
<Compile Include="$(AzureStorageSharedSources)TransferValidationOptionsExtensions.cs" LinkBase="Shared" />
1918
</ItemGroup>
2019
<ItemGroup>
2120
<Compile Include="$(AzureStorageSharedSources)SasExtensions.cs" LinkBase="Shared" />
2221
<Compile Include="$(AzureStorageSharedSources)SharedAccessSignatureCredentials.cs" LinkBase="Shared\Storage" />
2322
<Compile Include="$(AzureStorageSharedSources)StorageConnectionString.cs" LinkBase="Shared\Storage" />
2423
<Compile Include="$(AzureStorageSharedSources)StorageVersionExtensions.cs" LinkBase="Shared\Storage" />
24+
<Compile Include="$(AzureStorageSharedSources)TransferValidationOptionsExtensions.cs" LinkBase="Shared" />
2525
<Compile Include="$(AzureStorageSharedSources)UriExtensions.cs" LinkBase="Shared" />
2626
<Compile Include="$(AzureStorageSharedSources)UriQueryParamsCollection.cs" LinkBase="Shared\Storage" />
2727
<Compile Include="$(AzureStorageSharedSources)WindowStream.cs" LinkBase="Shared\Storage" />
2828
</ItemGroup>
2929
<ItemGroup>
3030
<Compile Include="$(AzureStorageSharedTestSources)\**\*.cs" LinkBase="Shared\Storage" />
31+
<Compile Include="$(MSBuildThisFileDirectory)..\..\Azure.Storage.Blobs\tests\BlobsClientTestFixtureAttribute.cs" LinkBase="Shared\Storage" />
32+
<Compile Include="$(MSBuildThisFileDirectory)..\..\Azure.Storage.Blobs\tests\DisposingContainer.cs" LinkBase="Shared\Storage" />
3133
<Compile Remove="$(AzureStorageSharedTestSources)\AzuriteFixture.cs"/>
3234
<Compile Remove="$(AzureStorageSharedTestSources)\AzuriteNUnitFixture.cs"/>
33-
<Compile Include="$(MSBuildThisFileDirectory)..\..\Azure.Storage.Blobs\tests\BlobsClientTestFixtureAttribute.cs" LinkBase="Shared\Storage" />
3435
<Compile Remove="$(AzureStorageSharedTestSources)\ClientSideEncryptionTestExtensions.cs" />
3536
<Compile Remove="$(AzureStorageSharedTestSources)\StorageTestBase.SasVersion.cs" />
3637
<Compile Remove="$(AzureStorageSharedTestSources)\TransferValidationTestBase.cs" />

sdk/storage/Azure.Storage.DataMovement/tests/BlobStorageResourceContainerTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Azure.Core.TestFramework;
99
using Azure.Storage.Blobs;
1010
using Azure.Storage.Blobs.Specialized;
11+
using Azure.Storage.Blobs.Tests;
1112
using Azure.Storage.DataMovement.Tests;
1213
using NUnit.Framework;
1314

@@ -75,7 +76,7 @@ public void Ctor_PublicUri()
7576
public async Task GetStorageResourcesAsync()
7677
{
7778
// Arrange
78-
await using DisposingBlobContainer test = await GetTestContainerAsync();
79+
await using DisposingContainer test = await GetTestContainerAsync();
7980
await SetUpContainerForListing(test.Container);
8081

8182
string folderName = "foo";
@@ -97,7 +98,7 @@ public async Task GetStorageResourcesAsync()
9798
[RecordedTest]
9899
public async Task GetChildStorageResourceAsync()
99100
{
100-
await using DisposingBlobContainer test = await GetTestContainerAsync();
101+
await using DisposingContainer test = await GetTestContainerAsync();
101102
await SetUpContainerForListing(test.Container);
102103

103104
string prefix = "foo";

0 commit comments

Comments
 (0)