Skip to content

Commit

Permalink
Using web options like ApiControllers does
Browse files Browse the repository at this point in the history
  • Loading branch information
wAsnk committed Oct 8, 2024
1 parent f0989db commit 226bf00
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace Lombiq.Tests.UI.Extensions;
Justification = "Disposed by the HttpClient.")]
public static class HttpClientUITestContextExtensions
{
private static readonly JsonSerializerOptions JsonSerializerOptions = new(JsonSerializerDefaults.Web);

public static HttpClient CreateClient(this UITestContext context)
{
var handler = new HttpClientHandler
Expand Down Expand Up @@ -210,13 +212,13 @@ public static async Task PostAndResponseStatusCodeShouldBeAsync(
/// Returns the serialized object as JSON using the default <see cref="JOptions"/> settings.
/// </summary>
public static string Serialize(object objectToSerialize) =>
JsonSerializer.Serialize(objectToSerialize, JOptions.Default);
JsonSerializer.Serialize(objectToSerialize, JsonSerializerOptions);

/// <summary>
/// Deserializes the provided <paramref name="content"/> to the given <typeparamref name="TObject"/> using the
/// default <see cref="JOptions"/> settings.
/// </summary>
public static TObject Deserialize<TObject>(string content)
where TObject : class =>
JsonSerializer.Deserialize<TObject>(content, JOptions.Default);
JsonSerializer.Deserialize<TObject>(content, JsonSerializerOptions);
}

0 comments on commit 226bf00

Please sign in to comment.