示例#1
0
        public void VisitMemberMemberBinding_Unchanged()
        {
            MemberBinding       memberBinding1      = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(0));
            MemberBinding       memberBinding2      = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(1));
            MemberMemberBinding memberMemberBinding = ExpressionInstanceCreator.CreateMemberMemberBinding(new[] { memberBinding1, memberBinding2 });

            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberBinding1)).Return(memberBinding1);
            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberBinding2)).Return(memberBinding2);
            var result = (MemberMemberBinding)InvokeAndCheckVisitObject("VisitMemberMemberBinding", memberMemberBinding);

            Assert.That(result, Is.SameAs(memberMemberBinding));
        }
示例#2
0
        public void VisitMemberBinding_Delegation_MemberBinding()
        {
            MemberMemberBinding memberMemberBinding = ExpressionInstanceCreator.CreateMemberMemberBinding(new MemberBinding[0]);

            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberMemberBinding)).CallOriginalMethod(OriginalCallOptions.CreateExpectation);
            Expect.Call(InvokeVisitMethod("VisitMemberMemberBinding", memberMemberBinding)).Return(memberMemberBinding);

            MockRepository.ReplayAll();
            object result = InvokeVisitMethod("VisitMemberBinding", memberMemberBinding);

            MockRepository.VerifyAll();

            Assert.That(result, Is.SameAs(memberMemberBinding));
        }
示例#3
0
        public void VisitMemberMemberBinding_Changed()
        {
            MemberBinding       memberBinding1      = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(0));
            MemberBinding       memberBinding2      = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(1));
            MemberBinding       memberBinding3      = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(2));
            MemberBinding       newMemberBinding    = Expression.Bind(typeof(List <int>).GetProperty("Capacity"), Expression.Constant(3));
            MemberMemberBinding memberMemberBinding =
                ExpressionInstanceCreator.CreateMemberMemberBinding(new[] { memberBinding1, memberBinding2, memberBinding3 });

            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberBinding1)).Return(memberBinding1);
            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberBinding2)).Return(newMemberBinding);
            Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberBinding3)).Return(memberBinding3);
            var result = (MemberMemberBinding)InvokeAndCheckVisitObject("VisitMemberMemberBinding", memberMemberBinding);

            Assert.That(result, Is.Not.SameAs(memberMemberBinding));
            Assert.That(result.Bindings, Is.EqualTo(new[] { memberBinding1, newMemberBinding, memberBinding3 }));
            Assert.That(result.BindingType, Is.EqualTo(memberMemberBinding.BindingType));
            Assert.That(result.Member, Is.EqualTo(memberMemberBinding.Member));
        }