public void ShouldApplyAToTargetSimpleTypeToANestedComplexTypeMemberConditionally() { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .From <string>().To <PublicEnumerable <int> >() .If(cxt => cxt.Source.Contains(',')) .Map(ctx => PublicEnumerable <int> .Parse(ctx.Source)).ToTarget(); mapper.GetPlanFor <PublicField <string> >().ToANew <PublicField <PublicEnumerable <int> > >(); } }
public void ShouldApplyAToTargetSimpleTypeToANestedComplexTypeMember() { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .From <string>().To <PublicEnumerable <int> >() .Map(ctx => PublicEnumerable <int> .Parse(ctx.Source)).ToTarget(); mapper.GetPlanFor <PublicField <string> >().ToANew <PublicField <PublicEnumerable <int> > >(); var source = new PublicField <string> { Value = "1,2,3" }; var result = mapper.Map(source).ToANew <PublicField <PublicEnumerable <int> > >(); result.ShouldNotBeNull(); result.Value.ShouldNotBeNull(); result.Value.ShouldBe(1, 2, 3); } }