-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from sergiobarriel/feature/enumerate-blobs
Added enumeration methods
- Loading branch information
Showing
13 changed files
with
289 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/AzureStorageWrapper/AzureStorageWrapper.Tests/Should/Enumerate/EnumerateShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using AzureStorageWrapper.Commands; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace AzureStorageWrapper.Tests.Should.Enumerate | ||
{ | ||
public class EnumerateShould : BaseShould | ||
{ | ||
private readonly IAzureStorageWrapper _azureStorageWrapper; | ||
private readonly ITestOutputHelper _output; | ||
|
||
public EnumerateShould(IAzureStorageWrapper azureStorageWrapper, ITestOutputHelper output) | ||
{ | ||
_azureStorageWrapper = azureStorageWrapper; | ||
_output = output; | ||
} | ||
|
||
// [Fact] | ||
// public async Task EnumerateBlobs_ShouldReturnAllBlobsFromAContainer() | ||
// { | ||
// var command = new EnumerateAllBlobs() | ||
// { | ||
// Container = "files" | ||
// }; | ||
// | ||
// var references = await _azureStorageWrapper.EnumerateAllBlobsAsync(command); | ||
// | ||
// _output.WriteLine($"Enumerating {references.References.Count()} references"); | ||
// | ||
// Assert.True(references.References.Any()); | ||
// | ||
// } | ||
|
||
[Fact] | ||
public async Task EnumerateBlobs_WithContinuationToken_ShouldReturnBlobsPageByPage() | ||
{ | ||
var firstIterationReferences = await _azureStorageWrapper.EnumerateBlobsAsync(new EnumerateBlobs() | ||
{ | ||
Container = "files", | ||
Size = 10, | ||
}); | ||
|
||
_output.WriteLine($"Enumerating {firstIterationReferences.References.Count()} references"); | ||
|
||
Assert.True(firstIterationReferences.References.Any()); | ||
|
||
var secondIterationReferences = await _azureStorageWrapper.EnumerateBlobsAsync(new EnumerateBlobs() | ||
{ | ||
Container = "files", | ||
Size = 10, | ||
ContinuationToken = firstIterationReferences.ContinuationToken | ||
}); | ||
|
||
_output.WriteLine($"Enumerating {secondIterationReferences.References.Count()} references"); | ||
|
||
Assert.True(secondIterationReferences.References.Any()); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/AzureStorageWrapper/AzureStorageWrapper.Tests/Should/Services/UriShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Xunit; | ||
using Xunit; | ||
|
||
namespace AzureStorageWrapper.Tests.Should | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/AzureStorageWrapper/AzureStorageWrapper/Commands/EnumerateAllBlobs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using AzureStorageWrapper.Exceptions; | ||
|
||
namespace AzureStorageWrapper.Commands | ||
{ | ||
public class EnumerateAllBlobs | ||
{ | ||
public string Container { get; set; } | ||
|
||
internal void Validate() | ||
{ | ||
if (string.IsNullOrEmpty(Container)) | ||
throw new AzureStorageWrapperException($"{nameof(Container)} is empty!"); | ||
|
||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/AzureStorageWrapper/AzureStorageWrapper/Commands/EnumerateBlobs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using AzureStorageWrapper.Exceptions; | ||
|
||
namespace AzureStorageWrapper.Commands | ||
{ | ||
public class EnumerateBlobs | ||
{ | ||
public string Container { get; set; } | ||
public int Size { get; set; } | ||
public string ContinuationToken { get; set; } | ||
|
||
internal void Validate() | ||
{ | ||
if (string.IsNullOrEmpty(Container)) | ||
throw new AzureStorageWrapperException($"{nameof(Container)} is empty!"); | ||
|
||
if (Size <= 0) | ||
throw new AzureStorageWrapperException($"{nameof(Size)} should be greater than zero."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.