Skip to content

Commit

Permalink
📝 Clean up namespaces (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureKrome authored Dec 7, 2023
1 parent cd25e4b commit 24a9308
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 147 deletions.
39 changes: 0 additions & 39 deletions SimpleAzure.Storage.HybridQueue.sln

This file was deleted.

57 changes: 57 additions & 0 deletions SimpleAzure.Storage.HybridQueues.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2FA40C61-766B-49BC-8F27-E32F27503D41}"
ProjectSection(SolutionItems) = preProject
ChangeLog.md = ChangeLog.md
global.json = global.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub", "GitHub", "{6E67C07E-34E7-4766-AF7C-709AEAADEFB6}"
ProjectSection(SolutionItems) = preProject
.github\CODE_OF_CONDUCT.md = .github\CODE_OF_CONDUCT.md
.github\CONTRIBUTING.md = .github\CONTRIBUTING.md
.github\FUNDING.yml = .github\FUNDING.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workflows", "Workflows", "{98455CD5-5B65-492E-AC6A-97CBB58FC3E9}"
ProjectSection(SolutionItems) = preProject
.github\workflows\MergeToMain.yml = .github\workflows\MergeToMain.yml
.github\workflows\PullRequest.yml = .github\workflows\PullRequest.yml
.github\workflows\Release.yml = .github\workflows\Release.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleAzure.Storage.HybridQueues", "src\SimpleAzure.Storage.HybridQueues\SimpleAzure.Storage.HybridQueues.csproj", "{5AE0AA98-E78B-470D-812B-783C58C4B31C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleAzure.Storage.HybridQueues.Tests", "src\SimpleAzure.Storage.HybridQueues.Tests\SimpleAzure.Storage.HybridQueues.Tests.csproj", "{C8836410-A303-4A19-A366-4DB4E37C0B80}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5AE0AA98-E78B-470D-812B-783C58C4B31C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AE0AA98-E78B-470D-812B-783C58C4B31C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AE0AA98-E78B-470D-812B-783C58C4B31C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AE0AA98-E78B-470D-812B-783C58C4B31C}.Release|Any CPU.Build.0 = Release|Any CPU
{C8836410-A303-4A19-A366-4DB4E37C0B80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8836410-A303-4A19-A366-4DB4E37C0B80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8836410-A303-4A19-A366-4DB4E37C0B80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8836410-A303-4A19-A366-4DB4E37C0B80}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6E67C07E-34E7-4766-AF7C-709AEAADEFB6} = {2FA40C61-766B-49BC-8F27-E32F27503D41}
{98455CD5-5B65-492E-AC6A-97CBB58FC3E9} = {6E67C07E-34E7-4766-AF7C-709AEAADEFB6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5EACA9DD-79BA-4F5C-806E-00E98C54BD5D}
EndGlobalSection
EndGlobal

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Testcontainers.Azurite;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Shouldly;

namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.AddMessageAsyncTests;
namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.HybridQueueTests;

public class AddMessageAsyncTests : CustomAzuriteTestContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Shouldly;

namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.AddMessagesAsyncTests;
namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.HybridQueueTests;

public class AddMessagesAsyncTests : CustomAzuriteTestContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Shouldly;

namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.DeleteMessageAsyncTests;
namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.HybridQueueTests;

public class DeleteMessageAsyncTests : CustomAzuriteTestContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.HybridQueueTests;

public class GetMessagesAsyncTests : CustomAzuriteTestContainer
{
private const string ValidNullJson = "null";

[Theory]
[InlineData(0)]
[InlineData(33)]
public async Task GetMessagesAsync_GivenAnInvalidMaxMessages_ShouldThrowAnException(int maxMessages)
{
// Arrange.
var cancellationToken = CancellationToken.None;

// Act.
var exception = await Should.ThrowAsync<ArgumentOutOfRangeException>(HybridQueue.GetMessagesAsync<string>(
maxMessages,
null,
cancellationToken));

// Assert.
exception.ShouldNotBeNull();
}

[Fact]
public async Task GetMessagesAsync_GivenNoMessageExists_ShouldReturnAnEmptyCollectoin()
{
// Arrange.
var cancellationToken = CancellationToken.None;

// Act.
var messages = await HybridQueue.GetMessagesAsync<string>(
10,
null,
cancellationToken);

// Assert.
messages.ShouldBeEmpty();
}

// We're checking that the message on the blob can be deserialzied ok.
// Maybe someone overwrote the original blob?
// Maybe someone manally placed a bad queue message which references the wrong/bad blob?
// Sure, this is a rare edge case.
[Fact]
public async Task GetMessagesAsync_GivenTheBlobItemCannotBeDeserialized_ShouldThrowAnException()
{
// Arrange.
var visibilityTimeout = TimeSpan.FromSeconds(1);
var cancellationToken = CancellationToken.None;
var message = new FakeMessage();

await HybridQueue.AddMessageAsync(message, null, true, cancellationToken); // Force the message onto the blob.
var retrievedMessage = await HybridQueue.GetMessageAsync<FakeMessage>(visibilityTimeout, cancellationToken); // Message is available asap.
retrievedMessage.ShouldNotBeNull();

// Wait a bit for the message to be available on the blob.
// Otherwise the next call is too quick and the blob isn't available yet.
await Task.Delay(visibilityTimeout, cancellationToken);

// Now we expect a "FakeMessage" type on the blob item, so lets hack the blob to be anything but that.
// We do this by deleting the existing one and uploading a new one.
var existingBlobClient = BlobContainerClient.GetBlobClient(retrievedMessage.BlobId.ToString());
var content = new BinaryData(ValidNullJson); // Bad Data - not a FakeMessage. This is valid JSON which is deserialized to null 🙃
await existingBlobClient.UploadAsync(content, true, cancellationToken);

// Act.
var exception = await Should.ThrowAsync<InvalidOperationException>(HybridQueue.GetMessageAsync<string>(cancellationToken));

// Assert.
exception.ShouldNotBeNull();
}

[Fact]
public async Task GetMessagesAsync_GivenTheQueueItemCannotBeDeserialized_ShouldThrowAnException()
{
// Arrange.
var cancellationToken = CancellationToken.None;

// Hack the message queue by manually placing a "bad" json payload onto the queue.
await QueueClient.SendMessageAsync(
ValidNullJson,
null,
null,
cancellationToken);

// Act.
var exception = await Should.ThrowAsync<InvalidOperationException>(HybridQueue.GetMessageAsync<FakeMessage>(cancellationToken));

// Assert.
exception.ShouldNotBeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SimpleAzure.Storage.HybridQueue\SimpleAzure.Storage.HybridQueue.csproj" />
<ProjectReference Include="..\SimpleAzure.Storage.HybridQueues\SimpleAzure.Storage.HybridQueues.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using Azure.Storage.Blobs;
Expand Down

0 comments on commit 24a9308

Please sign in to comment.