public void UseCamelCasing_WillThrow_IfContractResolver_IsNot_DefaultContractResolver()
        {
            // Arrange
            var options = new MvcNewtonsoftJsonOptions();

            options.SerializerSettings.ContractResolver = new FooContractResolver();
            var expectedMessage = Resources.FormatInvalidContractResolverForJsonCasingConfiguration(nameof(FooContractResolver), nameof(DefaultContractResolver));

            // Act & Assert
            var exception = Assert.Throws <InvalidOperationException>(
                () => options.UseCamelCasing(processDictionaryKeys: false));

            Assert.Equal(expectedMessage, actual: exception.Message);
        }
        public void UseCamelCasing_WillSet_CamelCasingStrategy_NameStrategy()
        {
            // Arrange
            var options = new MvcNewtonsoftJsonOptions();

            options.SerializerSettings.ContractResolver = new DefaultContractResolver()
            {
                NamingStrategy = new DefaultNamingStrategy()
            };
            var expected = typeof(CamelCaseNamingStrategy);

            // Act
            options.UseCamelCasing(processDictionaryKeys: true);
            var resolver = options.SerializerSettings.ContractResolver as DefaultContractResolver;
            var actual   = resolver.NamingStrategy;

            // Assert
            Assert.IsType(expected, actual);
        }
 public static void ConfigureMvcNewtonsoftJson(MvcNewtonsoftJsonOptions options)
 {
     options.UseCamelCasing(true);
     options.SerializerSettings.Converters.Add(new StringEnumConverter());
 }