public void CreatesSetterExpression()
        {
            var propInfo = typeof(SomeClass).GetProperties().First();

            var testee = new TargetValue <SomeClass>(propInfo);

            Expression <Func <SomeSourceClass, string> > getter = x => x.X;

            var expr = testee.CreateSetter(getter);

            var sourceInstance = new SomeSourceClass();
            var targetInstance = new SomeClass();

            (expr as Expression <Func <SomeClass, SomeSourceClass, SomeClass> >).Compile()(targetInstance, sourceInstance);

            Assert.AreEqual("a value", targetInstance.A);
        }
        public void CreatesSetterExpression()
        {
            var propInfo = typeof(SomeClass).GetProperties().First();

            var testee = new TargetValue<SomeClass>(propInfo);

            Expression<Func<SomeSourceClass, string>> getter = x => x.X;

            var expr = testee.CreateSetter(getter);

            var sourceInstance = new SomeSourceClass();
            var targetInstance = new SomeClass();

            (expr as Expression<Func<SomeClass, SomeSourceClass, SomeClass>>).Compile()(targetInstance, sourceInstance);

            Assert.AreEqual("a value", targetInstance.A);
        }
Example #3
0
 public SomeClass(SomeSourceClass source)
 {
     Helper.CopyItem(source, this);
 }