示例#1
0
        public void PropertyStatic()
        {
            MemberAssignment expr = Expression.Bind(MemberClass.GetStaticPropertyInfo(), Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#09");
            Assert.AreEqual("StaticProperty = 1", expr.ToString(), "Bind#10");
        }
示例#2
0
        public void FieldStatic()
        {
            MemberAssignment expr = Expression.Bind(MemberClass.GetStaticFieldInfo(), Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#05");
            Assert.AreEqual("StaticField = 1", expr.ToString(), "Bind#06");
        }
示例#3
0
        public void FieldRw()
        {
            MemberAssignment expr = Expression.Bind(MemberClass.GetRwFieldInfo(), Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#03");
            Assert.AreEqual("TestField2 = 1", expr.ToString(), "Bind#04");
        }
示例#4
0
        public void PropertyRw()
        {
            MemberAssignment expr = Expression.Bind(MemberClass.GetRwPropertyInfo(), Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#07");
            Assert.AreEqual("TestProperty2 = 1", expr.ToString(), "Bind#08");
        }
示例#5
0
        public void StaticField2()
        {
            var expr = Expression.Field(null, MemberClass.GetStaticFieldInfo());

            Assert.AreEqual(ExpressionType.MemberAccess, expr.NodeType, "Field#07");
            Assert.AreEqual(typeof(int), expr.Type, "Field#08");
            Assert.AreEqual("MemberClass.StaticField", expr.ToString(), "Field#09");
        }
        public void StaticProperty2()
        {
            MemberExpression expr = Expression.Property(null, MemberClass.GetStaticPropertyInfo());

            Assert.AreEqual(ExpressionType.MemberAccess, expr.NodeType, "Property#11");
            Assert.AreEqual(typeof(int), expr.Type, "Property#12");
            Assert.AreEqual("MemberClass.StaticProperty", expr.ToString(), "Property#13");
        }
示例#7
0
        public void InstanceProperty2()
        {
            var expr = Expression.Property(Expression.Constant(new MemberClass()), MemberClass.GetRoPropertyInfo());

            Assert.AreEqual(ExpressionType.MemberAccess, expr.NodeType, "Property#04");
            Assert.AreEqual(typeof(int), expr.Type, "Property#05");
            Assert.AreEqual("value(MonoTests.System.Linq.Expressions.MemberClass).TestProperty1", expr.ToString(), "Property#06");
        }
示例#8
0
 public void Method2()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         // This tests the MemberInfo version of Bind(): should raise an exception
         // because the argument is not a field or property accessor.
         Expression.Bind((MemberInfo)MemberClass.GetMethodInfo(), Expression.Constant(1));
     });
 }
示例#9
0
        public void PropertyAccessorStatic()
        {
            MethodInfo mi = typeof(MemberClass).GetMethod("get_StaticProperty");

            MemberAssignment expr = Expression.Bind(mi, Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#14");
            Assert.AreEqual("StaticProperty = 1", expr.ToString(), "Bind#15");
            Assert.AreEqual(MemberClass.GetStaticPropertyInfo(), expr.Member, "Bind#16");
        }
示例#10
0
        public void PropertyAccessor()
        {
            MethodInfo mi = typeof(MemberClass).GetMethod("get_TestProperty2");

            MemberAssignment expr = Expression.Bind(mi, Expression.Constant(1));

            Assert.AreEqual(MemberBindingType.Assignment, expr.BindingType, "Bind#11");
            Assert.AreEqual("TestProperty2 = 1", expr.ToString(), "Bind#12");
            Assert.AreEqual(MemberClass.GetRwPropertyInfo(), expr.Member, "Bind#13");
        }
        public void InstanceProperty3()
        {
            MethodInfo mi = typeof(MemberClass).GetMethod("get_TestProperty1");

            MemberExpression expr = Expression.Property(Expression.Constant(new MemberClass()), mi);

            Assert.AreEqual(ExpressionType.MemberAccess, expr.NodeType, "Property#07");
            Assert.AreEqual(typeof(int), expr.Type, "Property#08");
            Assert.AreEqual("value(MonoTests.System.Linq.Expressions.MemberClass).TestProperty1", expr.ToString(), "Property#09");
            Assert.AreEqual(MemberClass.GetRoPropertyInfo(), expr.Member, "Property#10");
        }
        public void StaticProperty3()
        {
            MethodInfo mi = typeof(MemberClass).GetMethod("get_StaticProperty");

            MemberExpression expr = Expression.Property(null, mi);

            Assert.AreEqual(ExpressionType.MemberAccess, expr.NodeType, "Property#14");
            Assert.AreEqual(typeof(int), expr.Type, "Property#15");
            Assert.AreEqual("MemberClass.StaticProperty", expr.ToString(), "Property#16");
            Assert.AreEqual(MemberClass.GetStaticPropertyInfo(), expr.Member, "Property#17");
        }
示例#13
0
 public void Arg2Null()
 {
     Expression.Bind(MemberClass.GetRwFieldInfo(), null);
 }
示例#14
0
 public void Arg2Null()
 {
     Assert.Throws <ArgumentNullException>(() => { Expression.Bind(MemberClass.GetRwFieldInfo(), null); });
 }
示例#15
0
 public void PropertyRo()
 {
     Assert.Throws <ArgumentException>(() => { Expression.Bind(MemberClass.GetRoPropertyInfo(), Expression.Constant(1)); });
 }
示例#16
0
 public void Event()
 {
     AssertEx.Throws <ArgumentException>(() => Expression.Bind(MemberClass.GetEventInfo(), Expression.Constant(1)));
 }
示例#17
0
 public void Method1()
 {
     // This tests the MethodInfo version of Bind(): should raise an exception
     // because the method is not an accessor.
     Expression.Bind(MemberClass.GetMethodInfo(), Expression.Constant(1));
 }
示例#18
0
 public void PropertyRo()
 {
     Expression.Bind(MemberClass.GetRoPropertyInfo(), Expression.Constant(1));
 }
示例#19
0
 public void Event()
 {
     Expression.Bind(MemberClass.GetEventInfo(), Expression.Constant(1));
 }