public void PropertyDescriptorNotCustomizedWhenDefaultValueIsNull() { TestPropertyDescriptor property = new TestPropertyDescriptor("prop", null); JsonDefaultValueAttribute attribute = new JsonDefaultValueAttribute(null); IServiceProvider sp = property; IPropertyDescriptorCustomization customization = attribute; customization.Apply(property); Assert.IsNull(sp.GetService(typeof(IObjectMemberExporter))); }
static void TestNamingCase(string baseName, NamingConvention testCase, UnderscoreConvention testUnder, string expected) { var attribute = new JsonMemberNamingConventionAttribute(testCase, testUnder); var property = CreateTestProperty(baseName); IPropertyDescriptorCustomization customization = attribute; customization.Apply(property); Assert.AreEqual(expected, property.CustomizedName); }
public void PropertyDescriptorCustomizedAsJsonObjectMemberExporter() { TestPropertyDescriptor property = new TestPropertyDescriptor("prop", 42); JsonDefaultValueAttribute attribute = new JsonDefaultValueAttribute(42); IServiceProvider sp = property; Assert.IsNull(sp.GetService(typeof(IObjectMemberExporter))); IPropertyDescriptorCustomization customization = attribute; customization.Apply(property); IObjectMemberExporter exporter = (IObjectMemberExporter)sp.GetService(typeof(IObjectMemberExporter)); Assert.IsNotNull(exporter); }