public void NonOverridenBaseProperty_SharedByChildren()
        {
            SerializerSettings     context   = new SerializerSettings();
            ITypeData <ChildClass> child     = context.Type <ChildClass>();
            ITypeData <BaseClass>  baseClass = context.Type <BaseClass>();

            Assert.AreSame(baseClass.Property(t => t.BaseProperty), child.Property(t => t.BaseProperty), "child BaseProperty");
        }
        public void IgnoreProperty_WhenFieldDoesntExist_ThrowsError()
        {
            SerializerSettings context = new SerializerSettings();
            ITypeData          handler = context.Type <SimpleObject>();

            handler.IgnoreProperty("Foo");
        }
        public void FindProperty_FindsIgnoredProperties()
        {
            SerializerSettings context      = new SerializerSettings();
            ITypeData          handler      = context.Type <IgnoredFieldClass>();
            IPropertyData      fieldHandler = handler.FindProperty("IVal");

            Assert.IsNotNull(fieldHandler, "Ignored property not found");
        }
        public void AttributeProcessors_CustomProcessor_XmlIgnore()
        {
            SerializerSettings context = new SerializerSettings();

            context.Types.AttributeProcessors.Add(new XmlIgnoreAttributeProcessor());
            ITypeData handler = context.Type <XmlIgnoreMock>();

            Assert.IsTrue(handler.FindProperty("Salary").Ignored, "XmlIgnore attribute not ignored");
        }
        public void TypeDataNamingStrategy_AppliedToProperties()
        {
            SerializerSettings config = new SerializerSettings();

            config.Types.PropertyNamingStrategy = new UnderscoreNamingStrategy();
            ITypeData <SimpleObject> td = config.Type <SimpleObject>();
            IPropertyData            pd = td.Property(t => t.ByteValue);

            Assert.AreEqual("Byte_Value", pd.Alias, "ByteValue Alias");
            IPropertyData bvByAlias = td.FindPropertyByAlias("Byte_Value");

            Assert.AreSame(pd, bvByAlias, "ByteValue By Alias");
        }
        public void IgnoreProperty_DoesNotDeleteField()
        {
            SerializerSettings context = new SerializerSettings();
            ITypeData          handler = context.Type <SimpleObject>();

            foreach (IPropertyData prop in handler.AllProperties)
            {
                ;  // force properties to load
            }
            handler.IgnoreProperty("IntValue");
            bool found = false;

            foreach (IPropertyData prop in handler.AllProperties)
            {
                if (prop.Name == "IntValue")
                {
                    found = true;
                }
            }
            Assert.IsTrue(found, "Ignored property deleted");
        }