public void Copy_SimpleClass_Class2CopyClass1_EqualFields() { //arrange SimpleClass Class1 = new SimpleClass(); Class1.Field1 = "hello"; Class1.Field2 = "hello22"; SimpleClass Class2 = new SimpleClass(); //act StaticHelper.Copy_SimpleClass(Class2, Class1); //assert Assert.AreEqual(Class2.Field1, Class1.Field1); Assert.AreEqual(Class2.Field2, Class1.Field2); }
public void ParseToBinaryExpression() { ConstantExpression cx; Expression left, right; BinaryExpression eq, add; Nullable <int> id = -100; // = default(Nullable<int>); int Id = 2011; var simple = new SimpleClass { ID = id, Name = "some name" }; left = Expression.MakeMemberAccess(Expression.Constant(simple), typeof(SimpleClass).GetField("ID")); right = Expression.Constant(id); ParseBinaryConvert(ref left, ref right); eq = Expression.MakeBinary(ExpressionType.Equal, left, right); //property Nullable<int> Customer.ID: left = Expression.MakeMemberAccess(Expression.Constant(Marc), typeof(Customer).GetProperty("ID")); //left: Nullable<int>, right: Nullable<int> //if (left.Type.Name == "Nullable`1") // left = Expression.Property(left, "Value"); right = Expression.Constant(Hans.ID); left = Expression.PropertyOrField(left, "Value"); right = Expression.PropertyOrField(right, "Value"); eq = Expression.MakeBinary(ExpressionType.Equal, left, right); //left = m; right = Expression.Constant(id); eq = Expression.MakeBinary(ExpressionType.Equal, left, right); //left: Nullable<int>, right: int eq = Expression.MakeBinary(ExpressionType.Add, left, Expression.Constant(Id)); }