Esempio n. 1
0
        protected void setUp()
        {
            pacific = new Voyage.Builder(new VoyageNumber("4567"), L.SHANGHAI)
                      .addMovement(L.LONGBEACH, new DateTime(1), new DateTime(2))
                      .build();

            transcontinental = new Voyage.Builder(new VoyageNumber("4567"), L.LONGBEACH)
                               .addMovement(L.CHICAGO, new DateTime(1), new DateTime(2))
                               .addMovement(L.NEWYORK, new DateTime(3), new DateTime(4))
                               .build();

            atlantic = new Voyage.Builder(new VoyageNumber("4556"), L.NEWYORK)
                       .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                       .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                       .build();

            voyage = new Voyage.Builder(new VoyageNumber("0123"), L.SHANGHAI)
                     .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                     .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                     .build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), L.NEWYORK)
                          .addMovement(L.STOCKHOLM, new DateTime(1), new DateTime(2))
                          .addMovement(L.HELSINKI, new DateTime(3), new DateTime(4))
                          .build();
        }
Esempio n. 2
0
        public void AddMovement_AddsLocationToSchedule()
        {
            var targetLocation = new Mock <Location>();

            targetLocation.Setup(tl => tl.SameIdentityAs(targetLocation.Object)).Returns(true);
            var sut = new Voyage.Builder(new VoyageNumber("eY72I01w"), Location.UNKNOWN)
                      .AddMovement(targetLocation.Object, default, default)
Esempio n. 3
0
        protected void setUp()
        {
            pacific = new Voyage.Builder(new VoyageNumber("4567"), L.SHANGHAI)
                .addMovement(L.LONGBEACH, new DateTime(1), new DateTime(2))
                .build();

            transcontinental = new Voyage.Builder(new VoyageNumber("4567"), L.LONGBEACH)
                .addMovement(L.CHICAGO, new DateTime(1), new DateTime(2))
                .addMovement(L.NEWYORK, new DateTime(3), new DateTime(4))
                .build();

            atlantic = new Voyage.Builder(new VoyageNumber("4556"), L.NEWYORK)
                .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                .build();

            voyage = new Voyage.Builder(new VoyageNumber("0123"), L.SHANGHAI)
                .addMovement(L.ROTTERDAM, new DateTime(1), new DateTime(2))
                .addMovement(L.GOTHENBURG, new DateTime(3), new DateTime(4))
                .build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), L.NEWYORK)
                .addMovement(L.STOCKHOLM, new DateTime(1), new DateTime(2))
                .addMovement(L.HELSINKI, new DateTime(3), new DateTime(4))
                .build();
         }
        protected void SetUp()
        {
            voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.SHANGHAI).
                AddMovement(SampleLocations.ROTTERDAM, dateTime, dateTime).
                AddMovement(SampleLocations.GOTHENBURG, dateTime, dateTime).
                Build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), SampleLocations.NEWYORK).
                AddMovement(SampleLocations.STOCKHOLM, dateTime, dateTime).
                AddMovement(SampleLocations.HELSINKI, dateTime, dateTime).
                Build();
        }
Esempio n. 5
0
        protected void SetUp()
        {
            voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.SHANGHAI).
                     AddMovement(SampleLocations.ROTTERDAM, dateTime, dateTime).
                     AddMovement(SampleLocations.GOTHENBURG, dateTime, dateTime).
                     Build();

            wrongVoyage = new Voyage.Builder(new VoyageNumber("666"), SampleLocations.NEWYORK).
                          AddMovement(SampleLocations.STOCKHOLM, dateTime, dateTime).
                          AddMovement(SampleLocations.HELSINKI, dateTime, dateTime).
                          Build();
        }
Esempio n. 6
0
        public void testFindByCargoId()
        {
            TrackingId trackingId = new TrackingId("FGH");
            Cargo      cargo      = cargoRepository.find(trackingId);

            Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin);
            Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination);

            IEnumerable <HandlingEvent> events =
                HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime();

            Assert.AreEqual(2, events.Count());

            HandlingEvent firstEvent = events.ElementAt(0);

            assertHandlingEvent(cargo, firstEvent, HandlingActivityType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.None);

            HandlingEvent secondEvent = events.ElementAt(1);

            Voyage hongkongMelbourneTokyoAndBack =
                new Voyage.Builder(new VoyageNumber("0303"), SampleLocations.HONGKONG).addMovement(SampleLocations.MELBOURNE,
                                                                                                   new DateTime(1),
                                                                                                   new DateTime(2)).addMovement(SampleLocations.TOKYO, new DateTime(3), new DateTime(4)).addMovement(SampleLocations.HONGKONG,
                                                                                                                                                                                                     new DateTime(5),
                                                                                                                                                                                                     new DateTime(6)).build();

            assertHandlingEvent(cargo,
                                secondEvent,
                                HandlingActivityType.LOAD,
                                SampleLocations.HONGKONG,
                                150,
                                110,
                                hongkongMelbourneTokyoAndBack);

            IEnumerable <Leg> legs = cargo.Itinerary.Legs;

            Assert.AreEqual(3, legs.Count());

            Leg firstLeg = legs.ElementAt(0);

            assertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE);

            Leg secondLeg = legs.ElementAt(1);

            assertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM);

            Leg thirdLeg = legs.ElementAt(2);

            assertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI);
        }
Esempio n. 7
0
        public void FindByCargoId()
        {
            TrackingId trackingId = new TrackingId("FGH");
            Cargo      cargo      = cargoRepository.Find(trackingId);

            Assert.AreEqual(SampleLocations.STOCKHOLM, cargo.Origin);
            Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin);
            Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination);

            Assert.IsNotNull(cargo.Delivery);

            IList <HandlingEvent> events =
                handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId).DistinctEventsByCompletionTime();

            Assert.AreEqual(2, events.Count);

            HandlingEvent firstEvent = events[0];

            AssertHandlingEvent(cargo, firstEvent, HandlingType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.NONE);

            HandlingEvent secondEvent = events[1];

            Voyage hongkongMelbourneTokyoAndBack = new Voyage.Builder(
                new VoyageNumber("0303"), SampleLocations.HONGKONG).
                                                   AddMovement(SampleLocations.MELBOURNE, new DateTime(), new DateTime()).
                                                   AddMovement(SampleLocations.TOKYO, new DateTime(), new DateTime()).
                                                   AddMovement(SampleLocations.HONGKONG, new DateTime(), new DateTime()).
                                                   Build();

            AssertHandlingEvent(cargo, secondEvent, HandlingType.LOAD, SampleLocations.HONGKONG, 150, 110,
                                hongkongMelbourneTokyoAndBack);

            IList <Leg> legs = cargo.Itinerary.Legs;

            Assert.AreEqual(3, legs.Count);

            Leg firstLeg = legs[0];

            AssertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE);

            Leg secondLeg = legs[1];

            AssertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM);

            Leg thirdLeg = legs[2];

            AssertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI);
        }
        public void testFindByCargoId()
        {
            TrackingId trackingId = new TrackingId("FGH");
            Cargo cargo = cargoRepository.find(trackingId);

            Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin);
            Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination);

            IEnumerable<HandlingEvent> events =
                HandlingEventRepository.lookupHandlingHistoryOfCargo(cargo).distinctEventsByCompletionTime();
            Assert.AreEqual(2, events.Count());

            HandlingEvent firstEvent = events.ElementAt(0);
            assertHandlingEvent(cargo, firstEvent, HandlingActivityType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.None);

            HandlingEvent secondEvent = events.ElementAt(1);

            Voyage hongkongMelbourneTokyoAndBack =
                new Voyage.Builder(new VoyageNumber("0303"), SampleLocations.HONGKONG).addMovement(SampleLocations.MELBOURNE,
                    new DateTime(1),
                    new DateTime(2)).addMovement(SampleLocations.TOKYO, new DateTime(3), new DateTime(4)).addMovement(SampleLocations.HONGKONG,
                        new DateTime(5),
                        new DateTime(6)).build();

            assertHandlingEvent(cargo,
                secondEvent,
                HandlingActivityType.LOAD,
                SampleLocations.HONGKONG,
                150,
                110,
                hongkongMelbourneTokyoAndBack);

            IEnumerable<Leg> legs = cargo.Itinerary.Legs;
            Assert.AreEqual(3, legs.Count());

            Leg firstLeg = legs.ElementAt(0);
            assertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE);

            Leg secondLeg = legs.ElementAt(1);
            assertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM);

            Leg thirdLeg = legs.ElementAt(2);
            assertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI);
        }
Esempio n. 9
0
        public void FindByCargoId()
        {
            TrackingId trackingId = new TrackingId("FGH");
            Cargo cargo = cargoRepository.Find(trackingId);
            Assert.AreEqual(SampleLocations.STOCKHOLM, cargo.Origin);
            Assert.AreEqual(SampleLocations.HONGKONG, cargo.RouteSpecification.Origin);
            Assert.AreEqual(SampleLocations.HELSINKI, cargo.RouteSpecification.Destination);

            Assert.IsNotNull(cargo.Delivery);

            IList<HandlingEvent> events =
                handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId).DistinctEventsByCompletionTime();
            Assert.AreEqual(2, events.Count);

            HandlingEvent firstEvent = events[0];
            AssertHandlingEvent(cargo, firstEvent, HandlingType.RECEIVE, SampleLocations.HONGKONG, 100, 160, Voyage.NONE);

            HandlingEvent secondEvent = events[1];

            Voyage hongkongMelbourneTokyoAndBack = new Voyage.Builder(
                new VoyageNumber("0303"), SampleLocations.HONGKONG).
                AddMovement(SampleLocations.MELBOURNE, new DateTime(), new DateTime()).
                AddMovement(SampleLocations.TOKYO, new DateTime(), new DateTime()).
                AddMovement(SampleLocations.HONGKONG, new DateTime(), new DateTime()).
                Build();

            AssertHandlingEvent(cargo, secondEvent, HandlingType.LOAD, SampleLocations.HONGKONG, 150, 110,
                                hongkongMelbourneTokyoAndBack);

            IList<Leg> legs = cargo.Itinerary.Legs;
            Assert.AreEqual(3, legs.Count);

            Leg firstLeg = legs[0];
            AssertLeg(firstLeg, "0101", SampleLocations.HONGKONG, SampleLocations.MELBOURNE);

            Leg secondLeg = legs[1];
            AssertLeg(secondLeg, "0101", SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM);

            Leg thirdLeg = legs[2];
            AssertLeg(thirdLeg, "0101", SampleLocations.STOCKHOLM, SampleLocations.HELSINKI);
        }
Esempio n. 10
0
        public void TestIsUnloadedAtFinalDestination()
        {
            Cargo cargo = SetUpCargoWithItinerary(SampleLocations.HANGZOU, SampleLocations.TOKYO,
                                                  SampleLocations.NEWYORK);

            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event unrelated to unloading at  destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(10), DateTime.Now, HandlingType.RECEIVE, SampleLocations.HANGZOU));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            Voyage voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.HANGZOU).
                            AddMovement(SampleLocations.NEWYORK, DateTime.Now, DateTime.Now).
                            Build();

            // Adding an unload event, but not at the final destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(20), DateTime.Now, HandlingType.UNLOAD, SampleLocations.TOKYO,
                                  voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event in the final destination, but not unload
            events.Add(
                new HandlingEvent(cargo, new DateTime(30), DateTime.Now, HandlingType.CUSTOMS, SampleLocations.NEWYORK));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Finally, cargo is unloaded at final destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(40), DateTime.Now, HandlingType.UNLOAD, SampleLocations.NEWYORK,
                                  voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsTrue(cargo.Delivery.IsUnloadedAtDestination);
        }
Esempio n. 11
0
        public void TestIsUnloadedAtFinalDestination()
        {
            Cargo cargo = SetUpCargoWithItinerary(SampleLocations.HANGZOU, SampleLocations.TOKYO,
                                                  SampleLocations.NEWYORK);
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event unrelated to unloading at  destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(10), DateTime.Now, HandlingType.RECEIVE, SampleLocations.HANGZOU));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            Voyage voyage = new Voyage.Builder(new VoyageNumber("0123"), SampleLocations.HANGZOU).
                AddMovement(SampleLocations.NEWYORK, DateTime.Now, DateTime.Now).
                Build();

            // Adding an unload event, but not at the final destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(20), DateTime.Now, HandlingType.UNLOAD, SampleLocations.TOKYO,
                                  voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Adding an event in the final destination, but not unload
            events.Add(
                new HandlingEvent(cargo, new DateTime(30), DateTime.Now, HandlingType.CUSTOMS, SampleLocations.NEWYORK));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsFalse(cargo.Delivery.IsUnloadedAtDestination);

            // Finally, cargo is unloaded at final destination
            events.Add(
                new HandlingEvent(cargo, new DateTime(40), DateTime.Now, HandlingType.UNLOAD, SampleLocations.NEWYORK,
                                  voyage));
            cargo.DeriveDeliveryProgress(new HandlingHistory(events));
            Assert.IsTrue(cargo.Delivery.IsUnloadedAtDestination);
        }