public void Test() { var baseTracker = A.Fake <ITracker>(); var geocodeDb = A.Fake <IGeocodeDb>(); var baseTrackingData = new TrackingData(); baseTrackingData.Activity.Add(new Activity { LocationDescription = "Green Bay, WI" }); baseTrackingData.Activity.Add(new Activity { LocationDescription = "Seattle, WA" }); A.CallTo(() => baseTracker.GetTrackingData("abc")).Returns(baseTrackingData); A.CallTo(() => geocodeDb.GetCity("Green Bay", "WI")).Returns(new CityRecord() { Latitude = 10, Longitude = 11 }); A.CallTo(() => geocodeDb.GetCity("Seattle", "WA")).Returns(new CityRecord() { Latitude = 12, Longitude = 13 }); var gt = new GeocodingTracker(baseTracker, geocodeDb); var td = gt.GetTrackingData("abc"); Assert.AreEqual(10, td.Activity[0].Latitude); Assert.AreEqual(11, td.Activity[0].Longitude); Assert.AreEqual(12, td.Activity[1].Latitude); Assert.AreEqual(13, td.Activity[1].Longitude); }
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; }
public void Test() { var baseTracker = A.Fake<ITracker>(); var geocodeDb = A.Fake<IGeocodeDb>(); var baseTrackingData = new TrackingData(); baseTrackingData.Activity.Add(new Activity {LocationDescription = "Green Bay, WI"}); baseTrackingData.Activity.Add(new Activity {LocationDescription = "Seattle, WA"}); A.CallTo(() => baseTracker.GetTrackingData("abc")).Returns(baseTrackingData); A.CallTo(() => geocodeDb.GetCity("Green Bay", "WI")).Returns(new CityRecord() {Latitude = 10, Longitude = 11}); A.CallTo(() => geocodeDb.GetCity("Seattle", "WA")).Returns(new CityRecord() { Latitude = 12, Longitude = 13 }); var gt = new GeocodingTracker(baseTracker, geocodeDb); var td = gt.GetTrackingData("abc"); Assert.AreEqual(10, td.Activity[0].Latitude); Assert.AreEqual(11, td.Activity[0].Longitude); Assert.AreEqual(12, td.Activity[1].Latitude); Assert.AreEqual(13, td.Activity[1].Longitude); }