/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Http/Http.Extensions/test/JsonOptionsTests.cs
48 строк
2 KB
William Godbe
Rename Microsoft.Aspnetcore.Testing to Microsoft.AspNetCore.InternalTesting (#51713)
02 ноя 2023, 03:15
Не верифицирован
02 ноя 2023, 03:15
fc8deca
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json.Serialization.Metadata; using Microsoft.AspNetCore.Http.Json; using Microsoft.AspNetCore.InternalTesting; using Microsoft.DotNet.RemoteExecutor; namespace Microsoft.AspNetCore.Http.Extensions; public class JsonOptionsTests { [ConditionalFact] [RemoteExecutionSupported] public void DefaultSerializerOptions_SetsTypeInfoResolverEmptyResolver_WhenJsonIsReflectionEnabledByDefaultFalse() { var options = new RemoteInvokeOptions(); options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", false.ToString()); using var remoteHandle = RemoteExecutor.Invoke(static () => { // Arrange var options = JsonOptions.DefaultSerializerOptions; // Assert Assert.NotNull(options.TypeInfoResolver); Assert.IsAssignableFrom<IJsonTypeInfoResolver>(options.TypeInfoResolver); }, options); } [ConditionalFact] [RemoteExecutionSupported] public void DefaultSerializerOptions_SetsTypeInfoResolverToDefault_WhenJsonIsReflectionEnabledByDefaultTrue() { var options = new RemoteInvokeOptions(); options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", true.ToString()); using var remoteHandle = RemoteExecutor.Invoke(static () => { // Arrange var options = JsonOptions.DefaultSerializerOptions; // Assert Assert.NotNull(options.TypeInfoResolver); Assert.IsType<DefaultJsonTypeInfoResolver>(options.TypeInfoResolver); }, options); } }