예제 #1
0
 public void ValidHotelDTOCommand_ExceptionThrown()
 {
     Assert.Throws <RequiredAttributeException>(() =>
     {
         HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(null);
         command.Execute();
     });
 }
예제 #2
0
 public void ValidHotelDTOCommand_NoExceptionThrown()
 {
     Assert.DoesNotThrow(() =>
     {
         HotelMapper _HotelMapper         = MapperFactory.createHotelMapper();
         HotelDTO result                  = _HotelMapper.CreateDTO(_hotel);
         HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(result);
         command.Execute();
     });
 }
예제 #3
0
 public void ValidHotelDTOCommand_LocationExceptionThrown()
 {
     Assert.Throws <RequiredAttributeException>(() =>
     {
         HotelMapper _HotelMapper         = MapperFactory.createHotelMapper();
         HotelDTO result                  = _HotelMapper.CreateDTO(_hotel);
         result.Location                  = null;
         HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(result);
         command.Execute();
     });
 }
예제 #4
0
        /// <summary>
        ///     Metodo para crear una Entidad  a partir de una DTO
        /// </summary>
        /// <param name="hotelDto">DTO de tipo hotel a ser convertida</param>
        /// <returns>un Hotel de tipo Entitidad</returns>
        /// <exception cref="RequiredAttributeException">Algun atributo requerido estaba como null</exception>
        public Hotel CreateEntity(HotelDTO hotelDto)
        {
            HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(hotelDto);

            command.Execute();
            Hotel entity = EntityFactory.CreateHotel(hotelDto.Id, hotelDto.Name, hotelDto.AmountOfRooms,
                                                     hotelDto.RoomCapacity, hotelDto.IsActive, hotelDto.AddressSpecification,
                                                     hotelDto.PricePerRoom, hotelDto.Website, hotelDto.Phone,
                                                     hotelDto.Picture, hotelDto.Stars, hotelDto.Location.Id);

            return(entity);
        }
예제 #5
0
        /// <summary>
        ///     Metodo para crear una lista Entidad  a partir de una lista DTO
        /// </summary>
        /// <param name="dtos">lista deto de tipo hotel a ser convertida</param>
        /// <returns>Lista de Hotel de tipo Entitidad</returns>
        /// <exception cref="RequiredAttributeException">Algun atributo requerido estaba como null</exception>
        public List <Hotel> CreateEntityList(List <HotelDTO> dtos)
        {
            List <Hotel> entities = new List <Hotel>();

            foreach (HotelDTO hotelDto in dtos)
            {
                HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(hotelDto);
                command.Execute();
                entities.Add(EntityFactory.CreateHotel(hotelDto.Id, hotelDto.Name, hotelDto.AmountOfRooms,
                                                       hotelDto.RoomCapacity, hotelDto.IsActive, hotelDto.AddressSpecification,
                                                       hotelDto.PricePerRoom, hotelDto.Website, hotelDto.Phone,
                                                       hotelDto.Picture, hotelDto.Stars, hotelDto.Location.Id));
            }
            return(entities);
        }