-
-
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.
🔧 Case insensitive deserialization for complex json queue messages
- Loading branch information
Showing
2 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...re.Storage.HybridQueues.Tests/IntegrationTests/HybridQueueTests/ParseMessageAsyncTests.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,33 @@ | ||
using Azure.Storage.Queues.Models; | ||
|
||
|
||
namespace WorldDomination.SimpleAzure.Storage.HybridQueues.Tests.IntegrationTests.HybridQueueTests | ||
{ | ||
public class ParseMessageAsyncTests : CustomAzuriteTestContainer | ||
{ | ||
public record FakePerson(string Name, int Age); | ||
|
||
[Theory] | ||
[InlineData("{\"Name\": \"Anabel\", \"Age\": 30}")] // Note: Capitalized keys. | ||
[InlineData("{\"name\": \"Anabel\", \"age\": 30}")] // Note: Lowercase keys. | ||
[InlineData("{\"nAmE\": \"Anabel\", \"aGe\": 30}")] // Note: Mixed case keys. | ||
public async Task ParseMessageAsync_LowercaseJsonKeys_CaseInsensitive(string json) | ||
{ | ||
// Arrange. | ||
var queueMessage = QueuesModelFactory.QueueMessage( | ||
"1", | ||
"2", | ||
new BinaryData(json), | ||
0); | ||
|
||
// Act. | ||
var fakePerson = await HybridQueue.ParseMessageAsync<FakePerson>(queueMessage, CancellationToken.None); | ||
|
||
// Assert. | ||
fakePerson.ShouldNotBeNull(); | ||
fakePerson.Content.ShouldNotBeNull(); | ||
fakePerson.Content.Name.ShouldBe("Anabel"); | ||
fakePerson.Content.Age.ShouldBe(30); | ||
} | ||
} | ||
} |
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