Esempio n. 1
0
        public TrackingData GetTrackingData(string trackingNumber)
        {
            string requestXml  = TrackingRequest.GetTrackingRequest(trackingNumber, _username, _password);
            string responseXml = _postUtility.PostData(DEV_URL, requestXml);

            return(TrackingResponse.GetCommonTrackingData(responseXml));
        }
Esempio n. 2
0
        public void Parse_Not_Found_Response_Verify_Null_Tracking_Data()
        {
            var xml = getSampleResponse("NotFoundResponse.xml");
            var td  = TrackingResponse.GetCommonTrackingData(xml);

            Assert.IsTrue(td == null);
        }
Esempio n. 3
0
        public void Parse_Sample_Response_Verify_Activities()
        {
            string       xml = getSampleResponse("StandardResponse.xml");
            TrackingData td  = TrackingResponse.GetCommonTrackingData(xml);

            Assert.AreEqual(5, td.Activity.Count);

            Assert.AreEqual(DateTime.Parse("4-20-2001 8:12:00 am"), td.Activity[0].Timestamp);
            Assert.AreEqual("Picked up by DHL.", td.Activity[0].ShortDescription);

            Assert.AreEqual(DateTime.Parse("2001-04-19 9:46 am"), td.Activity[1].Timestamp);
            Assert.AreEqual("NORCROSS, GA, UNITED STATES", td.Activity[1].LocationDescription);
            Assert.AreEqual("Arrived at DHL facility.", td.Activity[1].ShortDescription);

            Assert.AreEqual(DateTime.Parse("2001-04-19 6:32 pm"), td.Activity[2].Timestamp);
            Assert.AreEqual("NORCROSS, GA, UNITED STATES", td.Activity[2].LocationDescription);
            Assert.AreEqual("Departing origin.", td.Activity[2].ShortDescription);

            Assert.AreEqual(DateTime.Parse("2001-04-20 11:45 am"), td.Activity[3].Timestamp);
            Assert.AreEqual("MACON, GA, UNITED STATES", td.Activity[3].LocationDescription);
            Assert.AreEqual("Delivery Attempted.", td.Activity[3].ShortDescription);

            Assert.AreEqual(DateTime.Parse("2001-04-23 12:18 pm"), td.Activity[4].Timestamp);
            Assert.AreEqual("MACON, GA, UNITED STATES", td.Activity[4].LocationDescription);
            Assert.AreEqual("Shipment delivered.", td.Activity[4].ShortDescription);
        }
Esempio n. 4
0
        public void UsageTerms()
        {
            var xml   = getSampleResponse("SampleResponse3.xml");
            var td    = TrackingResponse.GetCommonTrackingData(xml);
            var terms = td.UsageRequirements;

            Assert.IsTrue(terms.Length > 20);
        }
Esempio n. 5
0
        public void Parse_Sample_Response3_Verify_Activities()
        {
            var xml = getSampleResponse("SampleResponse3.xml");
            var td  = TrackingResponse.GetCommonTrackingData(xml);

            //10 steps + 1 pickup step
            //Assert.AreEqual(11, td.Activity.Count);
        }
        /// <summary>
        ///		Parses the HTML response from DHL and extracts the tracking data.
        /// </summary>
        /// <param name="html">
        ///		The HTML response from the DHL track request web site.
        /// </param>
        /// <returns>
        ///		The parsed tracking data.
        /// </returns>
        public static TrackingData GetCommonTrackingData(string html)
        {
            if (html.Contains("The following Tracking Number(s) are not valid"))
            {
                return(new TrackingData
                {
                    TrackerName = TrackingResponse.TRACKER_NAME,
                    UsageRequirements = DhlTracker.USAGE_REQUIREMENTS,
                    Activity = new List <Activity>()
                });
            }

            return(TrackingResponse.GetCommonTrackingData(GetDhlTrackingXml(html)));
        }