public void UseMemberCasing_WillThrow_IfContractResolver_IsNot_DefaultContractResolver() { // Arrange var options = new MvcJsonOptions(); options.SerializerSettings.ContractResolver = new FooContractResolver(); var expectedMessage = Resources.FormatInvalidContractResolverForJsonCasingConfiguration(nameof(FooContractResolver), nameof(DefaultContractResolver)); // Act & Assert var exception = Assert.Throws <InvalidOperationException>( () => options.UseMemberCasing()); Assert.Equal(expectedMessage, actual: exception.Message); }
public void UseMemberCasing_WillSet_DefaultNamingStrategy_AsNamingStrategy() { // Arrange var options = new MvcJsonOptions(); options.SerializerSettings.ContractResolver = new DefaultContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }; var expected = typeof(DefaultNamingStrategy); // Act options.UseMemberCasing(); var resolver = options.SerializerSettings.ContractResolver as DefaultContractResolver; var actual = resolver.NamingStrategy; // Assert Assert.IsType(expected, actual); }