Ejemplo n.º 1
0
        public void CallOperationUpdateArgument()
        {
            var o1 = new NotificationObject <string>()
            {
                Value1 = "Test",
                Value2 = "Te",
            };

            var op = new CallOperation <bool>(new OperationContext(),
                                              Expression.Call(
                                                  Expression.MakeMemberAccess(
                                                      Expression.Constant(o1),
                                                      typeof(NotificationObject <string>).GetProperty("Value1")),
                                                  typeof(string).GetMethod("StartsWith", new Type[] { typeof(string) }),
                                                  Expression.MakeMemberAccess(
                                                      Expression.Constant(o1),
                                                      typeof(NotificationObject <string>).GetProperty("Value2"))));

            Assert.IsTrue(op.Value);

            o1.Value2 = "st";
            Assert.IsFalse(op.Value);

            o1.Value2 = "Te";
            Assert.IsTrue(op.Value);
        }
Ejemplo n.º 2
0
        public void Test_read()
        {
            var src = new NotificationObject <string>()
            {
                Value1 = "Test",
            };

            var op = new MemberAccessOperation <string>(new OperationContext(),
                                                        Expression.MakeMemberAccess(
                                                            Expression.Constant(src),
                                                            typeof(NotificationObject <string>).GetProperty("Value1")));

            Assert.AreEqual("Test", op.Value);
        }
Ejemplo n.º 3
0
        public void MemberInitOperationRead()
        {
            var src = new NotificationObject <string>()
            {
                Value1 = "Test",
            };

            var op = new MemberInitOperation <NotificationObject <string> >(new OperationContext(),
                                                                            Expression.MemberInit(
                                                                                Expression.New(typeof(NotificationObject <string>)),
                                                                                Expression.Bind(typeof(NotificationObject <string>).GetProperty("Value2"),
                                                                                                Expression.MakeMemberAccess(
                                                                                                    Expression.Constant(src),
                                                                                                    typeof(NotificationObject <string>).GetProperty("Value1")))));

            Assert.AreEqual("Test", op.Value.Value2);
        }