Skip to content

Commit 0ac58fb

Browse files
committed
Ready for deploy
1 parent 8799427 commit 0ac58fb

File tree

64 files changed

+1202
-867
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1202
-867
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,5 @@ ASALocalRun/
405405
.localhistory/
406406

407407
# Sensetive data
408-
App.config
408+
App.config
409+
appsettings.json

az-appservice-dotnet.MSTest/UnitTest1.cs

-10
This file was deleted.

az-appservice-dotnet.MSTest/Usings.cs

-1
This file was deleted.

az-appservice-dotnet.MSTest/az-appservice-dotnet.MSTest.csproj

-24
This file was deleted.

az-appservice-dotnet.nUnit/Usings.cs

-1
This file was deleted.

az-appservice-dotnet.nUnit/az-appservice-dotnet.nUnit.csproj

-25
This file was deleted.

az-appservice-dotnet.nUnit/services/v1/FakeFileProviderService/GetFileObjectTest.cs

-40
This file was deleted.

az-appservice-dotnet.sln

-12
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "az-appservice-dotnet", "az-
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "az-appservice-dotnet.xUnit", "az-appservice-dotnet.xUnit\az-appservice-dotnet.xUnit.csproj", "{EC930BCF-7CE0-4E27-82BB-F7C1754EEF73}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "az-appservice-dotnet.nUnit", "az-appservice-dotnet.nUnit\az-appservice-dotnet.nUnit.csproj", "{6CF3129B-1C2F-4DAE-B81C-1861ACC2C5BB}"
11-
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "az-appservice-dotnet.MSTest", "az-appservice-dotnet.MSTest\az-appservice-dotnet.MSTest.csproj", "{3CCB2931-9411-4579-9C2C-536DA2A991D0}"
13-
EndProject
1410
Global
1511
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1612
Debug|Any CPU = Debug|Any CPU
@@ -25,14 +21,6 @@ Global
2521
{EC930BCF-7CE0-4E27-82BB-F7C1754EEF73}.Debug|Any CPU.Build.0 = Debug|Any CPU
2622
{EC930BCF-7CE0-4E27-82BB-F7C1754EEF73}.Release|Any CPU.ActiveCfg = Release|Any CPU
2723
{EC930BCF-7CE0-4E27-82BB-F7C1754EEF73}.Release|Any CPU.Build.0 = Release|Any CPU
28-
{6CF3129B-1C2F-4DAE-B81C-1861ACC2C5BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29-
{6CF3129B-1C2F-4DAE-B81C-1861ACC2C5BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
30-
{6CF3129B-1C2F-4DAE-B81C-1861ACC2C5BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
31-
{6CF3129B-1C2F-4DAE-B81C-1861ACC2C5BB}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{3CCB2931-9411-4579-9C2C-536DA2A991D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{3CCB2931-9411-4579-9C2C-536DA2A991D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{3CCB2931-9411-4579-9C2C-536DA2A991D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{3CCB2931-9411-4579-9C2C-536DA2A991D0}.Release|Any CPU.Build.0 = Release|Any CPU
3624
EndGlobalSection
3725
GlobalSection(SolutionProperties) = preSolution
3826
HideSolutionNode = FALSE

az-appservice-dotnet.xUnit/az-appservice-dotnet.xUnit.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
<ProjectReference Include="..\az-appservice-dotnet\az-appservice-dotnet.csproj" />
3030
</ItemGroup>
3131

32-
<ItemGroup>
33-
<Folder Include="routes\v1\" />
34-
</ItemGroup>
35-
3632
<ItemGroup>
3733
<Content Update="App.config">
3834
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>

az-appservice-dotnet.xUnit/models/v1/LongRunningWorkloads/ProgressTest.cs

-39
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Azure.Storage.Blobs;
2+
using Microsoft.Extensions.Configuration;
3+
4+
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider;
5+
6+
public class ContainerFixture : IDisposable
7+
{
8+
public readonly BlobContainerClient ContainerClient;
9+
public readonly List<string> DisposableBag = new();
10+
11+
public ContainerFixture()
12+
{
13+
var config = new ConfigurationBuilder()
14+
.AddJsonFile("appsettings.json", false)
15+
.Build();
16+
17+
string? connectionString = config.GetSection("BlobStorage")["ConnectionString"];
18+
if (connectionString == null)
19+
throw new Exception("Configuration is missing the PrimaryKey setting (BlobStorage:ConnectionString)");
20+
var containerName = "processed-files-test";
21+
var blobServiceClient = new BlobServiceClient(connectionString);
22+
ContainerClient = blobServiceClient.GetBlobContainerClient(containerName);
23+
}
24+
25+
public void Dispose()
26+
{
27+
foreach (var blob in DisposableBag)
28+
{
29+
ContainerClient.DeleteBlob(blob);
30+
}
31+
}
32+
33+
public az_appservice_dotnet.providers.Azure.v1.AzureBlobProvider GetProvider()
34+
{
35+
return new az_appservice_dotnet.providers.Azure.v1.AzureBlobProvider(ContainerClient);
36+
}
37+
}
38+
39+
[CollectionDefinition("AzureBlobService collection")]
40+
public class ContainerCollection : ICollectionFixture<ContainerFixture>
41+
{
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using az_appservice_dotnet.services;
2+
using az_appservice_dotnet.services.v1;
3+
using az_appservice_dotnet.services.v1.UploadedFiles;
4+
5+
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider;
6+
7+
public class FileProviderFixture : IDisposable
8+
{
9+
private readonly IFileProviderService _fileProviderService = new FakeFileProviderService();
10+
11+
private readonly List<string> _files = new();
12+
13+
public IFileProviderService.FileObject GetFileObject(string name, uint size)
14+
{
15+
var fileObejct = _fileProviderService.GetFileObject(name, size);
16+
_files.Add(fileObejct.Path);
17+
return fileObejct;
18+
}
19+
20+
public void Dispose()
21+
{
22+
foreach (var file in _files)
23+
{
24+
if (File.Exists(file))
25+
File.Delete(file);
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using az_appservice_dotnet.services;
2+
using az_appservice_dotnet.services.v1.UploadedFiles;
3+
4+
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureBlobProvider;
5+
6+
[Collection("AzureBlobService collection")]
7+
8+
public class StoreBlobAsyncTest: IClassFixture<FileProviderFixture>
9+
{
10+
readonly ContainerFixture _containerFixture;
11+
readonly FileProviderFixture _fileProviderFixture;
12+
13+
public StoreBlobAsyncTest(ContainerFixture containerFixture, FileProviderFixture fileProviderFixture)
14+
{
15+
_containerFixture = containerFixture;
16+
_fileProviderFixture = fileProviderFixture;
17+
}
18+
19+
[Fact]
20+
public async Task Should_ReturnUri()
21+
{
22+
// Arrange
23+
var provider = _containerFixture.GetProvider();
24+
var fileObject = _fileProviderFixture.GetFileObject("test.bin",1);
25+
// Act
26+
var actual = await provider.StoreBlobAsync(fileObject.Name, fileObject.Path);
27+
_containerFixture.DisposableBag.Add(fileObject.Name);
28+
// Assert
29+
var readResponse = await _containerFixture.ContainerClient.GetBlobClient(fileObject.Name).ExistsAsync();
30+
Assert.True(readResponse.Value);
31+
32+
Assert.IsType<Uri>(actual);
33+
var expectedUri = _containerFixture.ContainerClient.Uri.ToString() + '/' + fileObject.Name;
34+
Assert.Equal(expectedUri, actual.ToString());
35+
}
36+
37+
// Test for exception
38+
[Fact]
39+
public async Task Should_ThrowException()
40+
{
41+
// Arrange
42+
var provider = _containerFixture.GetProvider();
43+
var fileObject = new IFileProviderService.FileObject("test.bin","/nonexistent");
44+
// Act
45+
var exception = await Record.ExceptionAsync(() => provider.StoreBlobAsync(fileObject.Name, fileObject.Path));
46+
// Assert
47+
Assert.NotNull(exception);
48+
Assert.IsType<AggregateException>(exception);
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureSbPublishProcessingStateProvider;
2+
3+
public class Base: IDisposable
4+
{
5+
protected readonly ServiceBusSenderFixture _fixture;
6+
protected readonly az_appservice_dotnet.providers.Azure.v1.AzureSbPublishProcessingStateProvider _provider;
7+
8+
public Base(ServiceBusSenderFixture fixture)
9+
{
10+
_fixture = fixture;
11+
_provider = _fixture.GetProvider();
12+
}
13+
14+
public void Dispose()
15+
{
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using az_appservice_dotnet.services.v1.State;
2+
3+
namespace az_appservice_dotnet.xUnit.providers.v1.Azure.AzureSbPublishProcessingStateProvider;
4+
5+
[Collection("ServiceBusSender collection")]
6+
public class PublishStateAsyncTest : Base
7+
{
8+
public PublishStateAsyncTest(ServiceBusSenderFixture fixture) : base(fixture)
9+
{
10+
}
11+
12+
[Fact]
13+
public async Task Should_PublishState()
14+
{
15+
// Arrange
16+
var (messages, errors,_) = _fixture.RunProcessor();
17+
var state = new IProcessingStateService.State(
18+
"some-id-to-be-published",
19+
1,
20+
IProcessingStateService.Status.Created,
21+
null,
22+
null,
23+
"file1.txt",
24+
null);
25+
// Act
26+
var result = await _provider.PublishStateAsync(state);
27+
// TODO: Find a better way to wait for the message to be processed; semaphore?
28+
Thread.Sleep(1000);
29+
// Assert
30+
Assert.Equal(state, result);
31+
Assert.Empty(errors);
32+
Assert.Single(messages);
33+
var message = messages.First().Message.Body.ToString();
34+
Assert.Equal(state.Id, message);
35+
}
36+
}

0 commit comments

Comments
 (0)