Example #1
0
        public PackageTracker(IWebPoster webPoster, IGeocodeDb geocodeDb)
        {
            //Todo: This is a bad place to load these:
            var uspsUserName = WebConfigurationManager.AppSettings["UspsUserName"];
            var uspsPassword = WebConfigurationManager.AppSettings["UspsPassword"];

            var fedexKey = WebConfigurationManager.AppSettings["FedexKey"];
            var fedexPassword = WebConfigurationManager.AppSettings["FedexPassword"];
            var fedexAccountNumber = WebConfigurationManager.AppSettings["FedexAccountNumber"];
            var fedexMeterNumber = WebConfigurationManager.AppSettings["FedexMeterNumber"];

            var coreTrackers = new List<ITracker>();
            coreTrackers.Add(new Tracking.Simulation.SimulationTracker());
            coreTrackers.Add(new UpsTracker());
            coreTrackers.Add(new UspsTracker(new PostUtility(), uspsUserName, uspsPassword, true));
            coreTrackers.Add(new FedexTracker(new TrackService(), fedexKey, fedexPassword, fedexAccountNumber, fedexMeterNumber, false));
            //coreTrackers.Add(new DhlTracker(new PostUtility(), "", "");

            var multiTracker = new MultiTracker(coreTrackers);
            var cacheTracker = new CacheTracker(multiTracker);
            var emptyTracker = new EmptyTrackingNumberTracker(cacheTracker);
            var loggingTracker = new LoggingTracker(emptyTracker);
            var sanitizerTracker = new TrackingNumberStandardizerTracker(loggingTracker);
            var geocodingTracker = new GeocodingTracker(sanitizerTracker, geocodeDb);
            var errorHandlerTracker = new ErrorHandlerTracker(geocodingTracker);

            _defaultTracker = errorHandlerTracker;
        }
Example #2
0
        public void Two_Trackers_Neither_Work_Verify_Return_Null()
        {
            Expect.Call(_mt1.GetTrackingData("abc")).Return(null);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(null);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] { _mt1, _mt2 });
            Assert.AreEqual(null, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #3
0
        public void Two_Trackers_Neither_Work_Verify_Return_Null()
        {
            Expect.Call(_mt1.GetTrackingData("abc")).Return(null);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(null);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] {_mt1, _mt2});
            Assert.AreEqual(null, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #4
0
        public void One_Tracker_Verify_Pass_Through()
        {
            var td = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(td);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] { _mt1 });
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #5
0
        public void One_Tracker_Verify_Pass_Through()
        {
            var td = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(td);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] {_mt1});
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #6
0
        public void Two_Trackers_One_Works_Verify_Pass_Through_2()
        {
            var td = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(null);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(td);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] { _mt1, _mt2 });
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #7
0
        public void Two_Trackers_Both_Work_Verify_Return_First()
        {
            var td  = new TrackingData();
            var td2 = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(td);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(td2);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] { _mt1, _mt2 });
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #8
0
        public void Two_Trackers_Both_Work_Verify_Return_First()
        {
            var td = new TrackingData();
            var td2 = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(td);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(td2);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] {_mt1, _mt2});
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }
Example #9
0
        public void Two_Trackers_One_Works_Verify_Pass_Through_2()
        {
            var td = new TrackingData();

            Expect.Call(_mt1.GetTrackingData("abc")).Return(null);
            Expect.Call(_mt2.GetTrackingData("abc")).Return(td);

            _mocks.ReplayAll();

            _mt = new MultiTracker(new[] {_mt1, _mt2});
            Assert.AreEqual(td, _mt.GetTrackingData("abc"));

            _mocks.VerifyAll();
        }