public void ShouldMapOnToASetMethod() { var source = new PublicGetMethod <double>(5643723); var target = new PublicSetMethod <double>(); Mapper.Map(source).OnTo(target); target.Value.ShouldBe(source.GetValue()); }
public void ShouldCreateAMemberDerivedTargetFromADerivedSourceMember() { using (var mapper = Mapper.CreateNew()) { var source = new PublicProperty <Person> { Value = new Customer() }; var target = new PublicSetMethod <PersonViewModel>(); var result = mapper.Map(source).OnTo(target); result.Value.ShouldBeOfType <CustomerViewModel>(); } }
public void ShouldUseAConfiguredFactoryWithAComplexTypeMemberBinding() { using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .InstancesOf <PublicCtor <Address> >() .CreateUsing(ctx => new PublicCtor <Address>(new Address()) { Value = { Line2 = "Some Street" } }); var source = new PublicField <PersonViewModel> { Value = new PersonViewModel() }; var target = new PublicSetMethod <PublicCtor <Address> >(); var result = mapper.Map(source).OnTo(target); result.Value.ShouldNotBeNull(); result.Value.Value.ShouldNotBeNull(); result.Value.Value.Line2.ShouldBe("Some Street"); } }
public void ShouldCreateADerivedTypeInAMemberEnumerableUsingRuntimeTypes() { using (var mapper = Mapper.CreateNew()) { var source = new PublicProperty <object> { Value = new Collection <object> { new CustomerViewModel { Name = "Fred" }, new PersonViewModel { Name = "Bob" } } }; var target = new PublicSetMethod <IEnumerable <Person> >(); var result = mapper.Map(source).OnTo(target); result.Value.First().ShouldBeOfType <Customer>(); result.Value.Second().ShouldBeOfType <Person>(); } }