diff --git a/LeaderboardBackend.Test/Lib/TestInitCommonFields.cs b/LeaderboardBackend.Test/Lib/TestInitCommonFields.cs index 07d51fe0..ead004fd 100644 --- a/LeaderboardBackend.Test/Lib/TestInitCommonFields.cs +++ b/LeaderboardBackend.Test/Lib/TestInitCommonFields.cs @@ -1,18 +1,27 @@ using System.Text.Json; using System.Text.Json.Serialization; using LeaderboardBackend.Models.Entities; +using NodaTime; +using NodaTime.Serialization.SystemTextJson; namespace LeaderboardBackend.Test.Lib; internal record TestInitCommonFields { - public static JsonSerializerOptions JsonSerializerOptions { get; } = - new() + public static JsonSerializerOptions JsonSerializerOptions { get; private set; } + + static TestInitCommonFields() + { + JsonSerializerOptions = new(JsonSerializerDefaults.Web) { ReferenceHandler = ReferenceHandler.IgnoreCycles, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; + JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); + JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); + } + public static User Admin { get; } = new() {