-
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.
- Loading branch information
Showing
63 changed files
with
1,208 additions
and
852 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
az-appservice-dotnet.MSTest/az-appservice-dotnet.MSTest.csproj
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
az-appservice-dotnet.nUnit/az-appservice-dotnet.nUnit.csproj
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
az-appservice-dotnet.nUnit/services/v1/FakeFileProviderService/GetFileObjectTest.cs
This file was deleted.
Oops, something went wrong.
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
39 changes: 0 additions & 39 deletions
39
az-appservice-dotnet.xUnit/models/v1/LongRunningWorkloads/ProgressTest.cs
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
az-appservice-dotnet.xUnit/providers/v1/Azure/AzureBlobProvider/ContainerFixture.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,42 @@ | ||
using Azure.Storage.Blobs; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider; | ||
|
||
public class ContainerFixture : IDisposable | ||
{ | ||
public readonly BlobContainerClient ContainerClient; | ||
public readonly List<string> DisposableBag = new(); | ||
|
||
public ContainerFixture() | ||
{ | ||
var config = new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.json", false) | ||
.Build(); | ||
|
||
string? connectionString = config.GetSection("BlobStorage")["ConnectionString"]; | ||
if (connectionString == null) | ||
throw new Exception("Configuration is missing the PrimaryKey setting (BlobStorage:ConnectionString)"); | ||
var containerName = "processed-files-test"; | ||
var blobServiceClient = new BlobServiceClient(connectionString); | ||
ContainerClient = blobServiceClient.GetBlobContainerClient(containerName); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
foreach (var blob in DisposableBag) | ||
{ | ||
ContainerClient.DeleteBlob(blob); | ||
} | ||
} | ||
|
||
public az_appservice_dotnet.providers.Azure.v1.AzureBlobProvider GetProvider() | ||
{ | ||
return new az_appservice_dotnet.providers.Azure.v1.AzureBlobProvider(ContainerClient); | ||
} | ||
} | ||
|
||
[CollectionDefinition("AzureBlobService collection")] | ||
public class ContainerCollection : ICollectionFixture<ContainerFixture> | ||
{ | ||
} |
28 changes: 28 additions & 0 deletions
28
az-appservice-dotnet.xUnit/providers/v1/Azure/AzureBlobProvider/FileProviderFixture.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,28 @@ | ||
using az_appservice_dotnet.services; | ||
using az_appservice_dotnet.services.v1; | ||
using az_appservice_dotnet.services.v1.UploadedFiles; | ||
|
||
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider; | ||
|
||
public class FileProviderFixture : IDisposable | ||
{ | ||
private readonly IFileProviderService _fileProviderService = new FakeFileProviderService(); | ||
|
||
private readonly List<string> _files = new(); | ||
|
||
public IFileProviderService.FileObject GetFileObject(string name, uint size) | ||
{ | ||
var fileObejct = _fileProviderService.GetFileObject(name, size); | ||
_files.Add(fileObejct.Path); | ||
return fileObejct; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
foreach (var file in _files) | ||
{ | ||
if (File.Exists(file)) | ||
File.Delete(file); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
az-appservice-dotnet.xUnit/providers/v1/Azure/AzureBlobProvider/StoreBlobAsyncTest.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,50 @@ | ||
using az_appservice_dotnet.services; | ||
using az_appservice_dotnet.services.v1.UploadedFiles; | ||
|
||
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider; | ||
|
||
[Collection("AzureBlobService collection")] | ||
|
||
public class StoreBlobAsyncTest: IClassFixture<FileProviderFixture> | ||
{ | ||
readonly ContainerFixture _containerFixture; | ||
readonly FileProviderFixture _fileProviderFixture; | ||
|
||
public StoreBlobAsyncTest(ContainerFixture containerFixture, FileProviderFixture fileProviderFixture) | ||
{ | ||
_containerFixture = containerFixture; | ||
_fileProviderFixture = fileProviderFixture; | ||
} | ||
|
||
[Fact] | ||
public async Task Should_ReturnUri() | ||
{ | ||
// Arrange | ||
var provider = _containerFixture.GetProvider(); | ||
var fileObject = _fileProviderFixture.GetFileObject("test.bin",1); | ||
// Act | ||
var actual = await provider.StoreBlobAsync(fileObject.Name, fileObject.Path); | ||
_containerFixture.DisposableBag.Add(fileObject.Name); | ||
// Assert | ||
var readResponse = await _containerFixture.ContainerClient.GetBlobClient(fileObject.Name).ExistsAsync(); | ||
Assert.True(readResponse.Value); | ||
|
||
Assert.IsType<Uri>(actual); | ||
var expectedUri = _containerFixture.ContainerClient.Uri.ToString() + '/' + fileObject.Name; | ||
Assert.Equal(expectedUri, actual.ToString()); | ||
} | ||
|
||
// Test for exception | ||
[Fact] | ||
public async Task Should_ThrowException() | ||
{ | ||
// Arrange | ||
var provider = _containerFixture.GetProvider(); | ||
var fileObject = new IFileProviderService.FileObject("test.bin","/nonexistent"); | ||
// Act | ||
var exception = await Record.ExceptionAsync(() => provider.StoreBlobAsync(fileObject.Name, fileObject.Path)); | ||
// Assert | ||
Assert.NotNull(exception); | ||
Assert.IsType<AggregateException>(exception); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
az-appservice-dotnet.xUnit/providers/v1/Azure/AzureSbPublishProcessingStateProvider/Base.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,17 @@ | ||
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureSbPublishProcessingStateProvider; | ||
|
||
public class Base: IDisposable | ||
{ | ||
protected readonly ServiceBusSenderFixture _fixture; | ||
protected readonly az_appservice_dotnet.providers.Azure.v1.AzureSbPublishProcessingStateProvider _provider; | ||
|
||
public Base(ServiceBusSenderFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
_provider = _fixture.GetProvider(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...t.xUnit/providers/v1/Azure/AzureSbPublishProcessingStateProvider/PublishStateAsyncTest.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,36 @@ | ||
using az_appservice_dotnet.services.v1.State; | ||
|
||
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureSbPublishProcessingStateProvider; | ||
|
||
[Collection("ServiceBusSender collection")] | ||
public class PublishStateAsyncTest : Base | ||
{ | ||
public PublishStateAsyncTest(ServiceBusSenderFixture fixture) : base(fixture) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task Should_PublishState() | ||
{ | ||
// Arrange | ||
var (messages, errors,_) = _fixture.RunProcessor(); | ||
var state = new IProcessingStateService.State( | ||
"some-id-to-be-published", | ||
1, | ||
IProcessingStateService.Status.Created, | ||
null, | ||
null, | ||
"file1.txt", | ||
null); | ||
// Act | ||
var result = await _provider.PublishStateAsync(state); | ||
// TODO: Find a better way to wait for the message to be processed; semaphore? | ||
Thread.Sleep(1000); | ||
// Assert | ||
Assert.Equal(state, result); | ||
Assert.Empty(errors); | ||
Assert.Single(messages); | ||
var message = messages.First().Message.Body.ToString(); | ||
Assert.Equal(state.Id, message); | ||
} | ||
} |
Oops, something went wrong.