public void should_set_received_location_as_last_known_location() { var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("XYZ"), new RouteSpecification(_stockholm, _melbourne, DateTime.Now)); var handlingHistory = new HandlingHistory(new List<HandlingEvent> { new HandlingEvent(HandlingEventType.Receive, _stockholm, DateTime.Now, new DateTime(2007, 12, 1), cargo) }); cargo.DeriveDeliveryProgress(handlingHistory); Assert.Equal(_stockholm, cargo.Delivery.LastKnownLocation); }
public void should_test_misdirection() { var shanghai = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "SHANGHAI"); var gothenburg = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "GOTHENBURG"); var rotterdam = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "ROTTERDAM"); var hangzou = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HANGZOU"); //A cargo with no itinerary is not misdirected var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("TRKID"), new RouteSpecification(shanghai, gothenburg, DateTime.Now)); Assert.False(cargo.Delivery.IsMisdirected); cargo = SetUpCargoWithItinerary(shanghai, rotterdam, gothenburg); //A cargo with no handling events is not misdirected Assert.False(cargo.Delivery.IsMisdirected); var events = new List<HandlingEvent>(); //Happy path events.Add(new HandlingEvent(HandlingEventType.Receive, shanghai, new DateTime(10), new DateTime(20), cargo)); events.Add(new HandlingEvent(HandlingEventType.Load, shanghai, new DateTime(30), new DateTime(40), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Unload, rotterdam, new DateTime(50), new DateTime(60), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Load, rotterdam, new DateTime(70), new DateTime(80), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Unload, gothenburg, new DateTime(90), new DateTime(100), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Claim, gothenburg, new DateTime(110), new DateTime(120), cargo)); events.Add(new HandlingEvent(HandlingEventType.Customs, gothenburg, new DateTime(130), new DateTime(140), cargo)); cargo.DeriveDeliveryProgress(new HandlingHistory(events)); Assert.False(cargo.Delivery.IsMisdirected); //Try a couple of failing ones cargo = SetUpCargoWithItinerary(shanghai, rotterdam, gothenburg); events.Add(new HandlingEvent(HandlingEventType.Receive, hangzou, DateTime.Now, DateTime.Now, cargo)); cargo.DeriveDeliveryProgress(new HandlingHistory(events)); Assert.True(cargo.Delivery.IsMisdirected); cargo = SetUpCargoWithItinerary(shanghai, rotterdam, gothenburg); events.Add(new HandlingEvent(HandlingEventType.Receive, shanghai, new DateTime(10), new DateTime(20), cargo)); events.Add(new HandlingEvent(HandlingEventType.Load, shanghai, new DateTime(30), new DateTime(40), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Unload, rotterdam, new DateTime(50), new DateTime(60), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Load, rotterdam, new DateTime(70), new DateTime(80), cargo, _voyage)); cargo.DeriveDeliveryProgress(new HandlingHistory(events)); Assert.True(cargo.Delivery.IsMisdirected); cargo = SetUpCargoWithItinerary(shanghai, rotterdam, gothenburg); events.Add(new HandlingEvent(HandlingEventType.Receive, shanghai, new DateTime(10), new DateTime(20), cargo)); events.Add(new HandlingEvent(HandlingEventType.Load, shanghai, new DateTime(30), new DateTime(40), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Unload, rotterdam, new DateTime(50), new DateTime(60), cargo, _voyage)); events.Add(new HandlingEvent(HandlingEventType.Claim, rotterdam, DateTime.Now, DateTime.Now, cargo)); cargo.DeriveDeliveryProgress(new HandlingHistory(events)); Assert.True(cargo.Delivery.IsMisdirected); }
public void should_set_off_location_as_last_known_location() { var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("XYZ"), new RouteSpecification(_stockholm, _melbourne, DateTime.Now)); var handlingHistory = new HandlingHistory(new List<HandlingEvent> { new HandlingEvent(HandlingEventType.Load, _stockholm, DateTime.Now, new DateTime(2007, 12, 1), cargo, _voyage), new HandlingEvent(HandlingEventType.Unload, _hambourg, DateTime.Now, new DateTime(2007, 12, 2), cargo, _voyage), new HandlingEvent(HandlingEventType.Load, _hambourg, DateTime.Now, new DateTime(2007, 12, 3), cargo, _voyage), new HandlingEvent(HandlingEventType.Unload, _hongkong, DateTime.Now, new DateTime(2007, 12, 4), cargo, _voyage) }); cargo.DeriveDeliveryProgress(handlingHistory); Assert.Equal(_hongkong, cargo.Delivery.LastKnownLocation); }