public void ValidHotelDTOCommand_ExceptionThrown() { Assert.Throws <RequiredAttributeException>(() => { HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(null); command.Execute(); }); }
public void ValidHotelDTOCommand_NoExceptionThrown() { Assert.DoesNotThrow(() => { HotelMapper _HotelMapper = MapperFactory.createHotelMapper(); HotelDTO result = _HotelMapper.CreateDTO(_hotel); HotelDTOValidatorCommand command = CommandFactory.HotelDTOValidatorCommand(result); command.Execute(); }); }
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(); }); }
/// <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); }
/// <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); }