public void MapBatchToBatchDTOTest() { BatchMapper mapper = new BatchMapper(); Batch batch = new Batch(); batch.IdUser = this.CreateUser(); batch.Description = "Primer Lote"; batch.Name = "Lote1"; batch.Vehicles = new List <Vehicle>(); Vehicle vehicle = new Vehicle(); vehicle.Vin = "TEST1234"; batch.Vehicles.Add(vehicle); BatchDTO batchDTO = mapper.ToDTO(batch); Assert.AreEqual(batch.Id, batchDTO.Id); Assert.AreEqual(batch.IdUser.UserName, batchDTO.CreatorUserName); Assert.AreEqual(batch.Description, batchDTO.Description); Assert.AreEqual(batch.Name, batchDTO.Name); foreach (Vehicle ve in batch.Vehicles) { Assert.IsTrue(batchDTO.Vehicles.Contains(ve.Vin)); } }
public TransportDTO ToDTO(Transport transport) { UserMapper userMapper = new UserMapper(new RoleDAOImp()); BatchMapper batchMapper = new BatchMapper(); TransportDTO transportDTO = new TransportDTO(); transportDTO.Id = transport.Id; transportDTO.StartDate = transport.StartDate; transportDTO.EndDate = transport.EndDate; transportDTO.User = userMapper.ToDTO(transport.IdUser); List <BatchDTO> batchesDTO = new List <BatchDTO>(); foreach (Batch batch in transport.Batches) { BatchDTO batchDTO = batchMapper.ToDTO(batch); batchesDTO.Add(batchDTO); } transportDTO.Batches = batchesDTO; return(transportDTO); }