-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Utf8JsonWriterHelper to not ignore null dictionary values (#6689)
- Loading branch information
1 parent
e2732f1
commit 2e3590d
Showing
2 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
src/HotChocolate/AspNetCore/test/Transport.Http.Tests/OperationRequestTests.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,37 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
using CookieCrumble; | ||
using Moq; | ||
|
||
namespace HotChocolate.Transport.Http.Tests; | ||
|
||
public class OperationRequestTests | ||
{ | ||
[Fact] | ||
public async Task Should_WriteNullValues() | ||
{ | ||
// arrange | ||
var request = new OperationRequest( | ||
null, | ||
"abc", | ||
"myOperation", | ||
variables: new Dictionary<string, object?>() | ||
{ | ||
["abc"] = "def", | ||
["hij"] = null | ||
}); | ||
|
||
using var memory = new MemoryStream(); | ||
await using var writer = new Utf8JsonWriter(memory); | ||
|
||
// act | ||
request.WriteTo(writer); | ||
await writer.FlushAsync(); | ||
|
||
// assert | ||
var result = Encoding.UTF8.GetString(memory.ToArray()); | ||
Assert.Equal( | ||
"""{"id":"abc","operationName":"myOperation","variables":{"abc":"def","hij":null}}""", | ||
result); | ||
} | ||
} |