/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Mvc/Mvc.Core/test/JsonOptionsTest.cs
47 строк
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.InternalTesting; using Microsoft.DotNet.RemoteExecutor; namespace Microsoft.AspNetCore.Mvc; public class JsonOptionsTest { [ConditionalFact] [RemoteExecutionSupported] public void DefaultSerializerOptions_SetsTypeInfoResolverNull_WhenJsonIsReflectionEnabledByDefaultFalse() { var options = new RemoteInvokeOptions(); options.RuntimeConfigurationOptions.Add("System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault", false.ToString()); using var remoteHandle = RemoteExecutor.Invoke(static () => { // Arrange var options = new JsonOptions().JsonSerializerOptions; // 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 = new JsonOptions().JsonSerializerOptions; // Assert Assert.NotNull(options.TypeInfoResolver); Assert.IsType<DefaultJsonTypeInfoResolver>(options.TypeInfoResolver); }, options); } }