Ejemplo n.º 1
0
        public string OnBoardParcel(ParcelModel parcel)
        {
            try
            {
                // i.   Validation of parcel data
                _trackingLogic.ValidateParcel(parcel);

                // ii.  Create new Tracking Code
                string trackingCode = _trackingLogic.GenerateTrackingCode();
                parcel.TrackingCode = trackingCode;

                // iii. Get GPS coordinates for package address (using Geo Encoding Agent)
                // TODO save geo to DB, maybe save in parcel domain obj?
                GeoPoint geo = _geoAgent.EncodeAddress(string.Format("{0}, {1} {2}", parcel.Recipient.Street, parcel.Recipient.PostalCode, parcel.Recipient.City));
                parcel.Latitude  = geo.Lat;
                parcel.Longitude = geo.Lon;

                // iv.  Write data to database
                _trackingLogic.AddParcel(parcel);

                // v.   Return TrackingCode
                return(trackingCode);
            }
            catch (Exception ex)
            {
                throw new BLException("", ex);
            }
        }
Ejemplo n.º 2
0
        public void ValidateParcel_should_return_true()
        {
            // Arrange
            RecipientModel recipient = new RecipientModel
            {
                FirstName  = "Rudi",
                LastName   = "Recipient",
                Street     = "Poststraße",
                PostalCode = "A-1070",
                City       = "Poststadt"
            };
            ParcelModel parcel = new ParcelModel {
                Recipient = recipient, Weight = 1.0f
            };

            parcel.TrackingCode = "MOCKCODE";
            // Act
            var result = _tl.ValidateParcel(parcel);

            // Assert
            Assert.IsTrue(result);
        }