public void updateItineraries(VoyageNumber voyageNumber) { var voyage = voyageRepository.find(voyageNumber); var affectedCargos = cargoRepository.findCargosOnVoyage(voyage); foreach (Cargo cargo in affectedCargos) { var newItinerary = cargo.Itinerary.WithRescheduledVoyage(voyage); cargo.AssignToRoute(newItinerary); LOG.Info("Updated itinerary of cargo " + cargo); } }
public void testFindCargosOnVoyage() { Voyage voyage = voyageRepository.find(new VoyageNumber("0101")); IEnumerable <Cargo> cargos = cargoRepository.findCargosOnVoyage(voyage); Assert.AreEqual(3, cargos.Count()); foreach (Cargo cargo in cargos) { bool found = false; foreach (Leg leg in cargo.Itinerary.Legs) { if (leg.Voyage.sameAs(voyage)) { found = true; } } Assert.True(found, "Cargo " + cargo + " has no leg on voyage " + voyage); } Voyage voyage2 = voyageRepository.find(new VoyageNumber("0100S")); Assert.True(!cargoRepository.findCargosOnVoyage(voyage2).Any()); }