//[TestMethod] public void MappingConditionIsRespectedForNestedCollectionMembers() { var mapper = new MemberMapper(); int i = 10; mapper.CreateMapProposal<SourceTypeCollection, DestinationTypeCollection>() .ForMember(dest => dest.Nested).OnlyIf(src => i == 0) .FinalizeMap(); var source = new SourceTypeCollection { Nested = new List<NestedSourceType> { new NestedSourceType { Foo = "Bla" } } }; var result = mapper.Map<SourceTypeCollection, DestinationTypeCollection>(source); Assert.IsNull(result.Nested); //i = 0; result = mapper.Map<SourceTypeCollection, DestinationTypeCollection>(source); Assert.AreEqual("Bla", result.Nested.Single().Foo); }
//[TestMethod] public void MappingConditionIsRespectedForNestedCollectionMembers() { var mapper = new MemberMapper(); int i = 10; mapper.CreateMapProposal <SourceTypeCollection, DestinationTypeCollection>() .ForMember(dest => dest.Nested).OnlyIf(src => i == 0) .FinalizeMap(); var source = new SourceTypeCollection { Nested = new List <NestedSourceType> { new NestedSourceType { Foo = "Bla" } } }; var result = mapper.Map <SourceTypeCollection, DestinationTypeCollection>(source); Assert.IsNull(result.Nested); //i = 0; result = mapper.Map <SourceTypeCollection, DestinationTypeCollection>(source); Assert.AreEqual("Bla", result.Nested.Single().Foo); }
public void NestedCollectionPropertiesCanBeIgnored() { var mapper = new MemberMapper(); mapper.CreateMapProposal <SourceTypeCollection, DestinationTypeCollection>() .ForMember(dest => dest.Nested).Ignore() .FinalizeMap(); var source = new SourceTypeCollection { Nested = new List <NestedSourceType> { new NestedSourceType { Foo = "Bla" } } }; var result = mapper.Map <SourceTypeCollection, DestinationTypeCollection>(source); Assert.IsNull(result.Nested); }
public void NestedCollectionPropertiesCanBeIgnored() { var mapper = new MemberMapper(); mapper.CreateMapProposal<SourceTypeCollection, DestinationTypeCollection>() .ForMember(dest => dest.Nested).Ignore() .FinalizeMap(); var source = new SourceTypeCollection { Nested = new List<NestedSourceType> { new NestedSourceType { Foo = "Bla" } } }; var result = mapper.Map<SourceTypeCollection, DestinationTypeCollection>(source); Assert.IsNull(result.Nested); }