示例#1
0
        public void TestPropertyExclusion()
        {
            var cloner = new IlClonerFluent <TestClassWithPropertyExclusion>()
                         .Exclude(x => x.PropA)
                         .CreateCloner();

            var obj = new TestClassWithPropertyExclusion()
            {
                PropA = "ASDF"
            };

            var cloned = cloner(obj);

            Assert.AreNotEqual(obj.PropA, cloned.PropA);
            Assert.IsNull(cloned.PropA);
        }
示例#2
0
        public void TestFieldExclusion()
        {
            var cloner = new IlClonerFluent <TestClassWithFieldExclusion>()
                         .Exclude(x => x.FieldA)
                         .CreateCloner();

            var obj = new TestClassWithFieldExclusion()
            {
                FieldA = "ASDF"
            };

            var cloned = cloner(obj);

            Assert.AreNotEqual(obj.FieldA, cloned.FieldA);
            Assert.IsNull(cloned.FieldA);
        }