public void VisitMemberListBinding_Unchanged() { ElementInit elementInit1 = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(0)); ElementInit elementInit2 = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(1)); ReadOnlyCollection <ElementInit> elementInits = new List <ElementInit> (new[] { elementInit1, elementInit2 }).AsReadOnly(); MemberListBinding memberListBinding = ExpressionInstanceCreator.CreateMemberListBinding(elementInits); Expect.Call(InvokeVisitMethod("VisitElementInit", elementInit1)).Return(elementInit1); Expect.Call(InvokeVisitMethod("VisitElementInit", elementInit2)).Return(elementInit2); var result = (MemberListBinding)InvokeAndCheckVisitObject("VisitMemberListBinding", memberListBinding); Assert.That(result, Is.SameAs(memberListBinding)); }
public void VisitMemberBinding_Delegation_ListBinding() { MemberListBinding memberListBinding = ExpressionInstanceCreator.CreateMemberListBinding(new ElementInit[0]); Expect.Call(InvokeVisitMethod("VisitMemberBinding", memberListBinding)).CallOriginalMethod(OriginalCallOptions.CreateExpectation); Expect.Call(InvokeVisitMethod("VisitMemberListBinding", memberListBinding)).Return(memberListBinding); MockRepository.ReplayAll(); object result = InvokeVisitMethod("VisitMemberBinding", memberListBinding); MockRepository.VerifyAll(); Assert.That(result, Is.SameAs(memberListBinding)); }
public void VisitMemberListBinding_Changed() { ElementInit elementInit1 = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(0)); ElementInit elementInit2 = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(1)); ElementInit elementInit3 = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(2)); ElementInit newElementInit = Expression.ElementInit(typeof(List <int>).GetMethod("Add"), Expression.Constant(3)); ReadOnlyCollection <ElementInit> elementInits = new List <ElementInit> (new[] { elementInit1, elementInit2, elementInit3 }).AsReadOnly(); MemberListBinding memberListBinding = ExpressionInstanceCreator.CreateMemberListBinding(elementInits); Expect.Call(InvokeVisitMethod("VisitElementInit", elementInit1)).Return(elementInit1); Expect.Call(InvokeVisitMethod("VisitElementInit", elementInit2)).Return(newElementInit); Expect.Call(InvokeVisitMethod("VisitElementInit", elementInit3)).Return(elementInit3); var result = (MemberListBinding)InvokeAndCheckVisitObject("VisitMemberListBinding", memberListBinding); Assert.That(result, Is.Not.SameAs(memberListBinding)); Assert.That(result.Initializers, Is.EqualTo(new List <ElementInit> { elementInit1, newElementInit, elementInit3 })); Assert.That(result.BindingType, Is.EqualTo(memberListBinding.BindingType)); Assert.That(result.Member, Is.EqualTo(memberListBinding.Member)); }