public HandlingHistoryTests()
        {
            var shanghai = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "SHANGHAI");
            var dallas = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "DALLAS");
            var hongkong = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HONGKONG");

            _cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("ABC"), new RouteSpecification(shanghai, dallas, new DateTime(2009, 4, 1)));
            _voyage = new VoyageBuilder(new VoyageNumber("X25"), hongkong)
                                                                        .AddMovement(shanghai, DateTime.Now, DateTime.Now)
                                                                        .AddMovement(dallas, DateTime.Now, DateTime.Now)
                                                                        .Build();

            _handlingEvent1 = new HandlingEvent(HandlingEventType.Load, shanghai, new DateTime(100), new DateTime(2009, 3, 5), _cargo, _voyage);
            _handlingEvent1Duplicate = new HandlingEvent(HandlingEventType.Load, shanghai, new DateTime(200), new DateTime(2009, 3, 5), _cargo, _voyage);
            _handlingEvent2 = new HandlingEvent(HandlingEventType.Unload, dallas, new DateTime(150), new DateTime(2009, 3, 10), _cargo, _voyage);

            _handlingHistory = new HandlingHistory(new List<HandlingEvent> {_handlingEvent2, _handlingEvent1, _handlingEvent1Duplicate});
        }
Ejemplo n.º 2
0
 public ItineraryTests()
 {
     _voyage = new VoyageBuilder(new VoyageNumber("0123"), _shanghai)
                                 .AddMovement(_rotterdam, DateTime.Now, DateTime.Now)
                                 .AddMovement(_gothenburg, DateTime.Now, DateTime.Now)
                                 .Build();
     _wrongVoyage = new VoyageBuilder(new VoyageNumber("666"), _newyork)
                                 .AddMovement(new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "STOCKHOLM"), DateTime.Now, DateTime.Now)
                                 .AddMovement(_helsinki, DateTime.Now, DateTime.Now)
                                 .Build();
     _trackingId = new TrackingId("CARGO1");
     _routeSpecification = new RouteSpecification(_shanghai, _gothenburg, DateTime.Now);
     _cargo = new BookingApi.Domain.Cargo.Cargo(_trackingId, _routeSpecification);
     _itinerary = new Itinerary(new List<Leg>
                                	{
                                		new Leg(_voyage, _shanghai, DateTime.Now, _rotterdam, DateTime.Now),
                                     new Leg(_voyage, _rotterdam, DateTime.Now, _gothenburg, DateTime.Now)
                                	});
 }
 public HandlingEventTests()
 {
     var trackingId = new TrackingId("XYZ");
     _hongkong = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HONGKONG");
     _newYork = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "NEW YORK");
     _helsinki = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HELSINKI");
     _chicago = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "CHICAGO");
     _hambourg = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HAMBOURG");
     var routeSpecification = new RouteSpecification(_hongkong, _newYork, DateTime.Now);
     _cargo = new BookingApi.Domain.Cargo.Cargo(trackingId, routeSpecification);
     _voyage = new VoyageBuilder(new VoyageNumber("X25"), _hongkong)
                                                                 .AddMovement(_newYork, DateTime.Now, DateTime.Now)
                                                                 .Build();
     _voyage2 = new VoyageBuilder(new VoyageNumber("CM004"), _newYork)
                                                                 .AddMovement(_chicago, DateTime.Now, DateTime.Now)
                                                                 .Build();
     _voyage3 = new VoyageBuilder(new VoyageNumber("CM005"), _chicago)
                                                                 .AddMovement(_hambourg, DateTime.Now, DateTime.Now)
                                                                 .Build();
 }
Ejemplo n.º 4
0
		/// <summary>
		/// Creates new event.
		/// </summary>
		/// <param name="eventType">Type of the event.</param>
		/// <param name="location">The location where the event took place.</param>
		/// <param name="registrationDate">Registration time, the time the message is received.</param>
		/// <param name="completionDate">Completion time, the reported time that the event actually happened (e.g. the receive took place).</param>
		/// <param name="cargo">Cargo.</param>
		public HandlingEvent(HandlingEventType eventType, Location.Location location, DateTime registrationDate, DateTime completionDate, Cargo.Cargo cargo)
		{
			if (cargo == null)
				throw new ArgumentNullException("cargo", "Cargo is required.");
			if (location == null)
				throw new ArgumentNullException("location", "Location is required.");
			if (registrationDate == default(DateTime))
				throw new ArgumentException("The registration date is required.", "registrationDate");
			if (completionDate == default(DateTime))
				throw new ArgumentException("The completion date is required.", "completionDate");

			if (eventType.RequiresVoyage())
				throw new ArgumentException("Voyage is required for event type event type : " + eventType, "eventType");

			_eventType = eventType;
			_completionDate = completionDate;
			_registrationDate = registrationDate;
			_location = location;
			_cargo = cargo;
			_voyage = null;
		}
Ejemplo n.º 5
0
        public void should_correctly_route_cargo()
        {
            var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("XYZ"), new RouteSpecification(_stockholm, _melbourne, DateTime.Now));
            var good = new Itinerary(new List<Leg> { new Leg(BookingApi.Domain.Voyage.Voyage.Empty, _stockholm, DateTime.Now, _melbourne, DateTime.Now) }); // modif refactoring
            var bad = new Itinerary(new List<Leg> { new Leg(BookingApi.Domain.Voyage.Voyage.Empty, _hongkong, DateTime.Now, _hambourg, DateTime.Now) }); // modif refactoring
            var acceptOnlyGood = new FakeRouteSpecification(cargo.Origine, cargo.RouteSpecification.Destination, DateTime.Now, good);

            cargo.SpecifyNewRoute(acceptOnlyGood);
            Assert.Equal(RoutingStatus.NotRouted, cargo.Delivery.RoutingStatus);

            cargo.AssignToRoute(bad);
            Assert.Equal(RoutingStatus.Misrouted, cargo.Delivery.RoutingStatus);

            cargo.AssignToRoute(good);
            Assert.Equal(RoutingStatus.Routed, cargo.Delivery.RoutingStatus);
        }
Ejemplo n.º 6
0
        public void should_construct_correctly_cargo()
        {
            var trackingId = new TrackingId("XYZ");
            var arrivalDeadline = new DateTime(2009, 3, 13);
            var routeSpecification = new RouteSpecification(_stockholm, _melbourne, arrivalDeadline);

            var cargo = new BookingApi.Domain.Cargo.Cargo(trackingId, routeSpecification);

            Assert.Equal(RoutingStatus.NotRouted, cargo.Delivery.RoutingStatus);
            Assert.Equal(TransportStatus.NotReceived, cargo.Delivery.TransportStatus);
            Assert.Equal(BookingApi.Domain.Location.Location.Unknown, cargo.Delivery.LastKnownLocation);
            Assert.Equal(BookingApi.Domain.Voyage.Voyage.Empty, cargo.Delivery.CurrentVoyage);
        }
Ejemplo n.º 7
0
        private BookingApi.Domain.Cargo.Cargo SetUpCargoWithItinerary(BookingApi.Domain.Location.Location origin, BookingApi.Domain.Location.Location midpoint, BookingApi.Domain.Location.Location destination)
        {
            var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, DateTime.Now));

            var itinerary = new Itinerary(new List<Leg>
                                          	{
                                          		new Leg(_voyage, origin, DateTime.Now, midpoint, DateTime.Now),
                                          		new Leg(_voyage, midpoint, DateTime.Now, destination, DateTime.Now)
                                          	});

            cargo.AssignToRoute(itinerary);

            return cargo;
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        public void should_set_unknown_location_as_last_known_location_when_no_events()
        {
            var cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("XYZ"), new RouteSpecification(_stockholm, _melbourne, DateTime.Now));

            Assert.Equal(BookingApi.Domain.Location.Location.Unknown, cargo.Delivery.LastKnownLocation);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        public void should_pass_equality()
        {
            var spec1 = new RouteSpecification(_stockholm, _hongkong, DateTime.Now);
            var spec2 = new RouteSpecification(_stockholm, _melbourne, DateTime.Now);

            var cargo1 = new BookingApi.Domain.Cargo.Cargo(new TrackingId("ABC"), spec1);
            var cargo2 = new BookingApi.Domain.Cargo.Cargo(new TrackingId("CBA"), spec1);
            var cargo3 = new BookingApi.Domain.Cargo.Cargo(new TrackingId("ABC"), spec2);
            var cargo4 = new BookingApi.Domain.Cargo.Cargo(new TrackingId("ABC"), spec1);

            Assert.True(cargo1.Equals(cargo4));
            Assert.True(cargo1.Equals(cargo3));
            Assert.True(cargo3.Equals(cargo4));
            Assert.False(cargo1.Equals(cargo2));
        }
Ejemplo n.º 13
0
        public DeliveryTests()
        {
            _chicago = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "CHICAGO");
            _hambourg = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HAMBOURG");
            _gdansk = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "GDANSK");

            _voyage = new BookingApi.Domain.Voyage.Voyage(new VoyageNumber("CM01"), new Schedule(new List<CarrierMovement>
                                                                                                 	{
                                                                                                 		new CarrierMovement(_chicago,
                                                                                                 		                    _hambourg,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now)
                                                                                                 	}));

            _voyage2 = new BookingApi.Domain.Voyage.Voyage(new VoyageNumber("CM03"), new Schedule(new List<CarrierMovement>
                                                                                                 	{
                                                                                                 		new CarrierMovement(_chicago,
                                                                                                 		                    _hambourg,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now),
                                                                                                        new CarrierMovement(_hambourg,
                                                                                                 		                    _gdansk,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now,
                                                                                                 		                    DateTime.
                                                                                                 		                    	Now)
                                                                                                 	}));

            _itineraryCHtoHAM = new Itinerary(new List<Leg>
                                       					{
                                       						new Leg(_voyage,
                                                                        _chicago,
                                                                        DateTime.Now,
                                                                        _hambourg,
                                                                        DateTime.Now)
                                       					});

            _itineraryCHtoGD = new Itinerary(new List<Leg>
                                       					{
                                       						new Leg(_voyage2,
                                                                        _chicago,
                                                                        DateTime.Now,
                                                                        _hambourg,
                                                                        DateTime.Now),
                                                            new Leg(_voyage2,
                                                                        _hambourg,
                                                                        DateTime.Now,
                                                                        _gdansk,
                                                                        DateTime.Now)
                                       					});

            _itineraryHAMtoCH = new Itinerary(new List<Leg>
                                       	{
                                       		new Leg(new BookingApi.Domain.Voyage.Voyage(new VoyageNumber("CM02"), new Schedule(new List<CarrierMovement>
                                       			                                                 									{
                                       			                                                 										new CarrierMovement(_hambourg,
                                                                                                                                                            _chicago,
                                       			                                                 															DateTime.Now,
                                       			                                                 															DateTime.Now)
                                       			                                                 									})),
                                                                                                                                    _hambourg,
                                                                                                                                    DateTime.Now,
                                                                                                                                    _chicago,
                                                                                                                                    DateTime.Now)
                                       	});

            _cargo = new BookingApi.Domain.Cargo.Cargo(new TrackingId("CAR01"), new RouteSpecification(_chicago, _hambourg, DateTime.Now));
        }