public void NewtonsoftJsonSettingsTest() { IDateTimeZoneProvider dateTimeZoneProvider = DateTimeZoneProviders.Tzdb; DateTime dateTimeUtc = new DateTime(2020, 05, 23, 10, 30, 50, DateTimeKind.Utc); var schemaExamples = new SchemaExamples(dateTimeZoneProvider, dateTimeUtc, "Europe/Moscow"); var nodaTimeSchemaSettings = new JsonSerializerSettings() .ConfigureForNodaTime(dateTimeZoneProvider) .CreateNodaTimeSchemaSettingsForNewtonsoftJson(schemaExamples: schemaExamples); CheckGeneratedSchema(nodaTimeSchemaSettings); }
public void SystemTextJsonSettingsTest() { IDateTimeZoneProvider dateTimeZoneProvider = DateTimeZoneProviders.Tzdb; DateTime dateTimeUtc = new DateTime(2020, 05, 23, 10, 30, 50, DateTimeKind.Utc); var schemaExamples = new SchemaExamples(dateTimeZoneProvider, dateTimeUtc, "Europe/Moscow"); var jsonSerializerOptions = new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; var nodaTimeSchemaSettings = jsonSerializerOptions .ConfigureForNodaTime(dateTimeZoneProvider) .CreateNodaTimeSchemaSettingsForSystemTextJson(schemaExamples: schemaExamples); CheckGeneratedSchema(nodaTimeSchemaSettings); }