Ejemplo n.º 1
0
        public void should_be_unloaded_at_final_destination()
        {
            var hangzou = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HANGZOU");
            var tokyo = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "TOKYO");
            var newyork = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "NEW YORK");

            var cargo = SetUpCargoWithItinerary(hangzou, tokyo, newyork);

            Assert.False(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event unrelated to unloading at final destination
            var events = new List<HandlingEvent>();
            events.Add(new HandlingEvent(HandlingEventType.Receive, hangzou, DateTime.Now, new DateTime(10), cargo));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.False(cargo.Delivery.IsUnloadedAtDestination);

            var voyage = new VoyageBuilder(new VoyageNumber("0123"), hangzou)
                .AddMovement(newyork, DateTime.Now, DateTime.Now)
                .Build();

            // Adding an unload event, but not at the final destination
            events.Add(new HandlingEvent(HandlingEventType.Unload, tokyo, DateTime.Now, new DateTime(20), cargo, voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.False(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event in the final destination, but not unload
            events.Add(new HandlingEvent(HandlingEventType.Customs, newyork, DateTime.Now, new DateTime(30), cargo));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.False(cargo.Delivery.IsUnloadedAtDestination);

            // Finally, cargo is unloaded at final destination
            events.Add(new HandlingEvent(HandlingEventType.Unload, newyork, DateTime.Now, new DateTime(40), cargo, voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.True(cargo.Delivery.IsUnloadedAtDestination);
        }
Ejemplo n.º 2
0
        public CargoTests()
        {
            _stockholm = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "STOCKHOLM");
            _hambourg = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HAMBOURG");
            _hongkong = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HONGKONG");
            _melbourne = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "MELBOURNE");

            _voyage = new VoyageBuilder(new VoyageNumber("0123"), _stockholm)
                .AddMovement(_hambourg, DateTime.Now, DateTime.Now)
                .AddMovement(_hongkong, DateTime.Now, DateTime.Now)
                .AddMovement(_melbourne, DateTime.Now, DateTime.Now)
                .Build();
        }
        public void should_the_same_handling_activities()
        {
            var voyage = new VoyageBuilder(new VoyageNumber("VOY01"),
                                           new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "CHICAGO"))
                                           .AddMovement(new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HAMBOURG"), DateTime.Now, DateTime.Now)
                                           .Build();
            var chicago = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "CHICAGO");

            var firstHandlingActivity = new HandlingActivity(HandlingEventType.Load, chicago, voyage);
            var secondHandlingActivity = new HandlingActivity(HandlingEventType.Load, chicago, voyage);

            Assert.Equal(firstHandlingActivity, secondHandlingActivity);
        }
        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});
        }
 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();
 }
        public void should_equal()
        {
            var chicago = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "CHICAGO");
            var hambourg = new BookingApi.Domain.Location.Location(UnLocodeHelpers.GetNewUnLocode(), "HAMBOURG");
            var departureTime = DateTime.Now;
            var arrivalTime = DateTime.Now;

            var cm1 = new CarrierMovement(chicago, hambourg, departureTime, arrivalTime);
            var cm2 = new CarrierMovement(chicago, hambourg, departureTime, arrivalTime);
            var cm3 = new CarrierMovement(hambourg, chicago, departureTime, arrivalTime);
            var cm4 = new CarrierMovement(hambourg, chicago, departureTime, arrivalTime);

            Assert.True(cm1.Equals(cm2));
            Assert.False(cm2.Equals(cm3));
            Assert.True(cm3.Equals(cm4));

            Assert.True(cm1== cm2);
            Assert.False(cm2 == cm3);
            Assert.True(cm3 == cm4);

            Assert.True(cm1.GetHashCode() == cm2.GetHashCode());
            Assert.False(cm2.GetHashCode() == cm3.GetHashCode());
            Assert.True(cm3.GetHashCode() == cm4.GetHashCode());
        }
Ejemplo n.º 7
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.º 8
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));
        }