示例#1
0
        public void AddJsonConverter_registersJsonSerializerOptions()
        {
            var services = new ServiceCollection();
            var builder  = new SerializerBuilder(services);

            builder.AddJsonConverter <JsonStringEnumConverter>();

            services.Should().ContainEquivalentOf(
                new
            {
                ServiceType        = typeof(JsonStringEnumConverter),
                ImplementationType = typeof(JsonStringEnumConverter)
            });
            services.BuildServiceProvider().GetService <IOptions <JsonSerializerOptions> >()?.Value
            .Should().BeEquivalentTo(new JsonSerializerOptions
            {
                Converters = { new JsonStringEnumConverter() }
            });
        }