Ejemplo n.º 1
0
        public void Map_Existing_With_Non_MemberInitExpression()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Customer, CustomerDTO>((c, mc) => mc.Map <Customer, CustomerDTO>(c));
            Assert.Throws <InvalidOperationException>(() => config.MapTo(new Customer(), new CustomerDTO()));
        }
Ejemplo n.º 2
0
        public void Map_Order_To_Existing()
        {
            var config = new MapConfiguration();

            config.RegisterMap <Order, OrderDTO>();
            config.RegisterMap <OrderDetail, OrderDetailDTO>();
            config.RegisterMap <Product, ProductDTO>();
            config.RegisterMap <Company, CompanyDTO>();

            var entity = _orders.First();
            var dto    = new OrderDTO();
            var mapDto = config.MapTo(entity, dto);

            Assert.Same(dto, mapDto);
            Assert.Equal(dto.OrderDetails.Count, entity.OrderDetails.Count);
        }