public void MapBatchDTOToBatchTest() { BatchMapper mapper = new BatchMapper(); BatchDTO batch = new BatchDTO(); batch.CreatorUserName = "******"; batch.Description = "Primer Lote"; batch.Name = "Lote1"; batch.Vehicles = new List <string>(); batch.Vehicles.Add("TEST1234"); batch.CreatorUserName = "******"; Batch batchEntity = mapper.ToEntity(batch); Assert.AreEqual(batch.Id, batchEntity.Id); Assert.AreEqual(batch.CreatorUserName, batchEntity.IdUser.UserName); Assert.AreEqual(batch.Description, batchEntity.Description); Assert.AreEqual(batch.Name, batchEntity.Name); Vehicle vehicle = batchEntity.Vehicles.Find(v => v.Vin == "TEST1234"); Assert.IsNotNull(vehicle); }
public Transport ToEntity(TransportDTO transportDTO) { UserMapper userMapper = new UserMapper(new RoleDAOImp()); BatchMapper batchMapper = new BatchMapper(); Transport transport = new Transport(); transport.Id = transportDTO.Id; transport.StartDate = transportDTO.StartDate; transport.EndDate = transportDTO.EndDate; transport.IdUser = userMapper.ToEntity(transportDTO.User); List <Batch> batches = new List <Batch>(); foreach (BatchDTO batchDTO in transportDTO.Batches) { Batch batch = batchMapper.ToEntity(batchDTO); batches.Add(batch); } transport.Batches = batches; return(transport); }