private static RoutingStatus CalculateRoutingStatus(Itinerary itinerary, RouteSpecification specification) { if (itinerary == null) { return(RoutingStatus.NotRouted); } return(specification.IsSatisfiedBy(itinerary) ? RoutingStatus.Routed : RoutingStatus.Misrouted); }
public void It_is_not_satisfied_if_destination_does_not_match() { var specification = new RouteSpecification(Krakow, Wroclaw, ArrivalDeadline); var itinerary = new Itinerary(new[] { new Leg(null, Krakow, new DateTime(2011, 12, 1), Warszawa, new DateTime(2011, 12, 2)) }); Assert.IsFalse(specification.IsSatisfiedBy(itinerary)); }
public void It_is_satisfied_if_origin_and_destination_match_and_deadline_is_not_exceeded() { var specification = new RouteSpecification(Krakow, Wroclaw, ArrivalDeadline); var itinerary = new Itinerary(new[] { new Leg(null, Krakow, new DateTime(2011, 12, 1), Warszawa, new DateTime(2011, 12, 2)), new Leg(null, Warszawa, new DateTime(2011, 12, 13), Wroclaw, ArrivalDeadline) }); Assert.IsTrue(specification.IsSatisfiedBy(itinerary)); }
/// <summary> /// Assigns cargo to a provided route. /// </summary> /// <param name="itinerary">New itinerary</param> public virtual void AssignToRoute(Itinerary itinerary) { if (itinerary == null) { throw new ArgumentNullException("itinerary"); } if (!_routeSpecification.IsSatisfiedBy(itinerary)) { throw new InvalidOperationException("Provided itinerary doesn't satisfy this cargo's route specification."); } Publish(this, new CargoAssignedToRouteEvent(itinerary, _deliveryStatus.Derive(_routeSpecification, itinerary))); }
private static RoutingStatus CalculateRoutingStatus(Itinerary itinerary, RouteSpecification specification) { if (itinerary == null) { return RoutingStatus.NotRouted; } return specification.IsSatisfiedBy(itinerary) ? RoutingStatus.Routed : RoutingStatus.Misrouted; }