Inheritance: System.Attribute, IPropertyDescriptorCustomization
 public void SetConvention()
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute();
     Assert.AreEqual(NamingConvention.None, attribute.Convention);
     attribute.Convention = NamingConvention.Pascal; 
     Assert.AreEqual(NamingConvention.Pascal, attribute.Convention);
 }
 public void CustomizationSkippedWhenNoneConvention()
 {
     TestPropertyDescriptor property = CreateTestProperty("foo");
     IPropertyDescriptorCustomization customization = new JsonMemberNamingConventionAttribute();
     customization.Apply(property);
     Assert.IsNull(property.CustomizedName);
 }
示例#3
0
        public void SetUnderscores()
        {
            var attribute = new JsonMemberNamingConventionAttribute();

            Assert.AreEqual(UnderscoreConvention.None, attribute.Underscores);
            attribute.Underscores = UnderscoreConvention.Separate;
            Assert.AreEqual(UnderscoreConvention.Separate, attribute.Underscores);
        }
示例#4
0
        public void CustomizationSkippedWhenNoneConvention()
        {
            var property = CreateTestProperty("foo");
            IPropertyDescriptorCustomization customization = new JsonMemberNamingConventionAttribute();

            customization.Apply(property);
            Assert.IsNull(property.CustomizedName);
        }
示例#5
0
        public void SetConvention()
        {
            var attribute = new JsonMemberNamingConventionAttribute();

            Assert.AreEqual(NamingConvention.None, attribute.Convention);
            attribute.Convention = NamingConvention.Pascal;
            Assert.AreEqual(NamingConvention.Pascal, attribute.Convention);
        }
示例#6
0
        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 CannotApplyToNullPropertyDescriptor()
 {
     IPropertyDescriptorCustomization customization = new JsonMemberNamingConventionAttribute();
     customization.Apply(null);
 }
 public void InitializeConvention()
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute(NamingConvention.Pascal);
     Assert.AreEqual(NamingConvention.Pascal, attribute.Convention);
 }
 public void DefaultInitializationYieldsNoneConvention()
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute();
     Assert.AreEqual(NamingConvention.None, attribute.Convention);
 }
 private static void TestNamingCase(string baseName, NamingConvention testCase, string expected) 
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute(testCase);
     TestPropertyDescriptor property = CreateTestProperty(baseName);
     IPropertyDescriptorCustomization customization = attribute;
     
     customization.Apply(property);
     
     Assert.AreEqual(expected, property.CustomizedName);
 }
 public void InitializeUnderscores()
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute(NamingConvention.Pascal, UnderscoreConvention.Separate);
     Assert.AreEqual(UnderscoreConvention.Separate, attribute.Underscores);
 }
 public void SetUnderscores()
 {
     JsonMemberNamingConventionAttribute attribute = new JsonMemberNamingConventionAttribute();
     Assert.AreEqual(UnderscoreConvention.None, attribute.Underscores);
     attribute.Underscores = UnderscoreConvention.Separate;
     Assert.AreEqual(UnderscoreConvention.Separate, attribute.Underscores);
 }
示例#13
0
        public void CannotApplyToNullPropertyDescriptor()
        {
            IPropertyDescriptorCustomization customization = new JsonMemberNamingConventionAttribute();

            customization.Apply(null);
        }
示例#14
0
        public void InitializeUnderscores()
        {
            var attribute = new JsonMemberNamingConventionAttribute(NamingConvention.Pascal, UnderscoreConvention.Separate);

            Assert.AreEqual(UnderscoreConvention.Separate, attribute.Underscores);
        }
示例#15
0
        public void InitializeConvention()
        {
            var attribute = new JsonMemberNamingConventionAttribute(NamingConvention.Pascal);

            Assert.AreEqual(NamingConvention.Pascal, attribute.Convention);
        }
示例#16
0
        public void DefaultInitializationYieldsNoneConvention()
        {
            var attribute = new JsonMemberNamingConventionAttribute();

            Assert.AreEqual(NamingConvention.None, attribute.Convention);
        }