public createHandlingEvent ( System.DateTime completionTime, TrackingId trackingId, VoyageNumber voyageNumber, UnLocode unlocode, HandlingActivityType type, OperatorCode operatorCode ) : HandlingEvent | ||
completionTime | System.DateTime | when the event was completed, for example finished loading |
trackingId | TrackingId | cargo tracking id |
voyageNumber | VoyageNumber | voyage number |
unlocode | UnLocode | United Nations Location Code for the location of the event |
type | HandlingActivityType | type of event |
operatorCode | OperatorCode | operator code |
return | HandlingEvent |
public HandlingEvent createHandlingEvent(DateTime completionTime, TrackingId trackingId,
VoyageNumber voyageNumber, UnLocode unlocode,
HandlingActivityType type, OperatorCode operatorCode)
{
var cargo = findCargo(trackingId);
var voyage = findVoyage(voyageNumber);
var location = findLocation(unlocode);
try
{
var registrationTime = DateTime.Now;
if(voyage == null)
{
return new HandlingEvent(cargo, completionTime, registrationTime, type, location);
}
else
{
return new HandlingEvent(cargo, completionTime, registrationTime, type, location, voyage, operatorCode);
}
}
catch(Exception e)
{
throw new CannotCreateHandlingEventException(e.Message, e);
}
}
public void setUp() { reportSubmission = MockRepository.GenerateMock<ReportSubmission>(); CargoRepository cargoRepository = new CargoRepositoryInMem(); HandlingEventRepository handlingEventRepository = new HandlingEventRepositoryInMem(); HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository, new VoyageRepositoryInMem(), new LocationRepositoryInMem()); TrackingId trackingId = new TrackingId("ABC"); RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG, L.ROTTERDAM, DateTime.Parse("2009-10-10")); Cargo cargo = new Cargo(trackingId, routeSpecification); cargoRepository.store(cargo); HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent( DateTime.Parse("2009-10-02"), trackingId, null, L.HONGKONG.UnLocode, HandlingActivityType.RECEIVE, new OperatorCode("ABCDE") ); handlingEventRepository.store(handlingEvent); cargo.Handled(handlingEvent.Activity); reportPusher = new ReportPusher(reportSubmission, cargoRepository, handlingEventRepository); eventSequenceNumber = handlingEvent.SequenceNumber; }