-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
19 changed files
with
154 additions
and
147 deletions.
There are no files selected for viewing
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
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 |
96 changes: 0 additions & 96 deletions
96
...Storage.HybridQueue.Tests/IntegrationTests/GetMessagesAsyncTests/GetMessagesAsyncTests.cs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion
1
.../IntegrationTests/AzuriteTestContainer.cs → .../IntegrationTests/AzuriteTestContainer.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,3 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Logging.Testing; | ||
using Testcontainers.Azurite; | ||
|
||
|
4 changes: 1 addition & 3 deletions
4
...MessageAsyncTests/AddMessageAsyncTests.cs → .../HybridQueueTests/AddMessageAsyncTests.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
4 changes: 1 addition & 3 deletions
4
...ssagesAsyncTests/AddMessagesAsyncTests.cs → ...HybridQueueTests/AddMessagesAsyncTests.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
4 changes: 1 addition & 3 deletions
4
...sageAsyncTests/DeleteMessageAsyncTests.cs → ...bridQueueTests/DeleteMessageAsyncTests.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
93 changes: 93 additions & 0 deletions
93
...ure.Storage.HybridQueues.Tests/IntegrationTests/HybridQueueTests/GetMessagesAsyncTests.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,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(); | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion
1
...eAzure.Storage.HybridQueue/HybridQueue.cs → ...Azure.Storage.HybridQueues/HybridQueue.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,3 @@ | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Text.Json; | ||
using Azure.Storage.Blobs; | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.