static void Main(string[] args) { IosContactName iosContactName = new IosContactName(); var wcfContactName = new WcfContactName() { Login = "******", FirstName = "Nick", LastName = "Perry", Age = 22, Address = new Address() { City = "London", Street = "Golden Lane" } }; Mapper mapper = new Mapper(); mapper.MapTypes<WcfContactName, IosContactName>(); mapper.ApplyMapping(wcfContactName, iosContactName); }
public void Should_be_able_to_map_properties_for_each_source() { var address1 = new Address() {City = "Lviv", Street = "Zolota"}; var address2 = new Address() {City = "Lviv", Street = "Horodotska"}; Mapper mapper = new Mapper(); List<Address> addresses = new List<Address> {address1, address2}; mapper.MapTypes<Address, AddressDto>(); IEnumerable<AddressDto> addressDtos = mapper.ApplyMappingContainer<Address, AddressDto>(addresses); Assert.IsTrue(addressDtos.Any(item => item.City == address1.City)); Assert.IsTrue(addressDtos.Any(item => item.City == address2.City)); }
public void Should_ignore_property_where_name_matches_but_different_type() { IosContactName iosContactName = new IosContactName(); var wcfContactName = new WcfContactName() { Login = "******", FirstName = "Nick", LastName = "Perry", Age = 22, Address = new Address() {City = "London", Street = "Golden Lane"} }; Mapper mapper = new Mapper(); mapper.MapTypes<WcfContactName, IosContactName>(); mapper.ApplyMapping(wcfContactName, iosContactName); Assert.AreEqual(null, iosContactName.Age); }
public void Should_set_values_where_name_matches_and_same_type_in_inner_class() { IosContactName iosContactName = new IosContactName(); var wcfContactName = new WcfContactName() { Login = "******", FirstName = "Nick", LastName = "Perry", Age = 22, Address = new Address() {City = "London", Street = "Golden Lane"} }; Mapper mapper = new Mapper(); mapper.MapTypes<WcfContactName, IosContactName>(); mapper.ApplyMapping(wcfContactName, iosContactName); Assert.AreEqual(wcfContactName.Address.City, "London"); }
public void Given_mapper_already_registered_should_throw_mapper_already_registered_exception() { Mapper mapper = new Mapper(); mapper.MapTypes<WcfContactName, IosContactName>(); mapper.MapTypes<WcfContactName, IosContactName>(); }
public void Should_throw_null_arg_exception_if_source_is_null() { IosContactName iosContactName = new IosContactName(); Mapper mapper = new Mapper(); mapper.MapTypes<WcfContactName, IosContactName>(); WcfContactName nullWcfContactName = null; mapper.ApplyMapping(nullWcfContactName, iosContactName); }