Esempio n. 1
0
        public void CanCreateTest()
        {
            var cargo = new Cargo(new TrackingId("XYZ"),
                                  new RouteSpecification(SampleLocations.HANGZOU, SampleLocations.HELSINKI,
                                                         DateTime.Now));

            var events = new List <HandlingEvent>
            {
                new HandlingEvent(cargo, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), HandlingType.RECEIVE,
                                  SampleLocations.HANGZOU),
                new HandlingEvent(cargo, DateTime.Now.AddDays(3), DateTime.Now.AddDays(4), HandlingType.LOAD,
                                  SampleLocations.HANGZOU, SampleVoyages.CM001),
                new HandlingEvent(cargo, DateTime.Now.AddDays(5), DateTime.Now.AddDays(6), HandlingType.UNLOAD,
                                  SampleLocations.HELSINKI, SampleVoyages.CM001)
            };

            cargo.DeriveDeliveryProgress(new HandlingHistory(events));

            var adapter = new CargoTrackingViewAdapter(cargo, events);

            Assert.AreEqual("XYZ", adapter.TrackingId);
            Assert.AreEqual("Hangzhou", adapter.Origin);
            Assert.AreEqual("Helsinki", adapter.Destination);
            Assert.AreEqual("In port Helsinki", adapter.GetStatusText());

            IEnumerator <HandlingEventViewAdapter> it = adapter.Events.GetEnumerator();

            it.MoveNext();
            HandlingEventViewAdapter evnt = it.Current;

            Assert.AreEqual("RECEIVE", evnt.Type);
            Assert.AreEqual("Hangzhou", evnt.Location);
            Assert.AreEqual(GetDateFormated(1), evnt.Time);
            Assert.AreEqual("", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);

            it.MoveNext();
            evnt = it.Current;
            Assert.AreEqual("LOAD", evnt.Type);
            Assert.AreEqual("Hangzhou", evnt.Location);
            Assert.AreEqual(GetDateFormated(3), evnt.Time);
            Assert.AreEqual("CM001", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);

            it.MoveNext();
            evnt = it.Current;
            Assert.AreEqual("UNLOAD", evnt.Type);
            Assert.AreEqual("Helsinki", evnt.Location);
            Assert.AreEqual(GetDateFormated(5), evnt.Time);
            Assert.AreEqual("CM001", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);
        }
        public void CanCreateTest()
        {
            var cargo = new Cargo(new TrackingId("XYZ"),
                                    new RouteSpecification(SampleLocations.HANGZOU, SampleLocations.HELSINKI,
                                                           DateTime.Now));

            var events = new List<HandlingEvent>
                             {
                                 new HandlingEvent(cargo, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2), HandlingType.RECEIVE,
                                                   SampleLocations.HANGZOU),
                                 new HandlingEvent(cargo, DateTime.Now.AddDays(3), DateTime.Now.AddDays(4), HandlingType.LOAD,
                                                   SampleLocations.HANGZOU, SampleVoyages.CM001),
                                 new HandlingEvent(cargo, DateTime.Now.AddDays(5), DateTime.Now.AddDays(6), HandlingType.UNLOAD,
                                                   SampleLocations.HELSINKI, SampleVoyages.CM001)
                             };

            cargo.DeriveDeliveryProgress(new HandlingHistory(events));

            var adapter = new CargoTrackingViewAdapter(cargo, events);

            Assert.AreEqual("XYZ", adapter.TrackingId);
            Assert.AreEqual("Hangzhou", adapter.Origin);
            Assert.AreEqual("Helsinki", adapter.Destination);
            Assert.AreEqual("In port Helsinki", adapter.GetStatusText());

            IEnumerator<HandlingEventViewAdapter> it = adapter.Events.GetEnumerator();

            it.MoveNext();
            HandlingEventViewAdapter evnt = it.Current;
            Assert.AreEqual("RECEIVE", evnt.Type);
            Assert.AreEqual("Hangzhou", evnt.Location);
            Assert.AreEqual(GetDateFormated(1), evnt.Time);
            Assert.AreEqual("", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);

            it.MoveNext();
            evnt = it.Current;
            Assert.AreEqual("LOAD", evnt.Type);
            Assert.AreEqual("Hangzhou", evnt.Location);
            Assert.AreEqual(GetDateFormated(3), evnt.Time);
            Assert.AreEqual("CM001", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);

            it.MoveNext();
            evnt = it.Current;
            Assert.AreEqual("UNLOAD", evnt.Type);
            Assert.AreEqual("Helsinki", evnt.Location);
            Assert.AreEqual(GetDateFormated(5), evnt.Time);
            Assert.AreEqual("CM001", evnt.VoyageNumber);
            Assert.IsTrue(evnt.IsExpected);
        }