Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
 public void Given_mapper_already_registered_should_throw_mapper_already_registered_exception()
 {
     Mapper mapper = new Mapper();
      mapper.MapTypes<WcfContactName, IosContactName>();
      mapper.MapTypes<WcfContactName, IosContactName>();
 }
Exemplo n.º 6
0
 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);
 }