public void TestInitialise() { _OriginalClassFactory = Factory.TakeSnapshot(); _ConfigurationStorage = TestUtilities.CreateMockSingleton <IConfigurationStorage>(); _ConfigurationStorage.Setup(r => r.Folder).Returns(ConfigurationFolder); _StandingDataManager = TestUtilities.CreateMockSingleton <IStandingDataManager>(); _StandingDataManagerLock = new object(); _StandingDataManager.Setup(r => r.Lock).Returns(_StandingDataManagerLock); _Implementation = Factory.Singleton.Resolve <IStandingDataUpdater>(); _Provider = new Mock <IStandingDataUpdaterProvider>(); _Implementation.Provider = _Provider.Object; _FileExists = new Dictionary <string, bool>(); foreach (var fileName in AllFileNames) { _FileExists.Add(fileName, true); } _Provider.Setup(p => p.FileExists(It.IsAny <string>())).Returns((string fileName) => { return(_FileExists[fileName.ToUpper()]); }); _ReadLines = new Dictionary <string, List <string> >(); foreach (var fileName in AllFileNames) { _ReadLines.Add(fileName, new List <string>()); } _Provider.Setup(p => p.ReadLines(It.IsAny <string>())).Returns((string fileName) => { return(_ReadLines[fileName.ToUpper()].ToArray()); }); _DownloadLines = new Dictionary <string, List <string> >(); foreach (var url in AllUrls) { _DownloadLines.Add(url, new List <string>()); } _Provider.Setup(p => p.DownloadLines(It.IsAny <string>())).Returns((string url) => { return(_DownloadLines[url.ToUpper()].ToArray()); }); _SavedLines = new Dictionary <string, List <string> >(); _Provider.Setup(p => p.WriteLines(It.IsAny <string>(), It.IsAny <string[]>())).Callback((string fileName, string[] lines) => { var key = fileName.ToUpper(); var value = new List <string>(lines); _SavedLines.Add(key, value); }); _DownloadedCompressedFiles = new Dictionary <string, string>(); _Provider.Setup(r => r.DownloadAndDecompressFile(It.IsAny <string>(), It.IsAny <string>())).Callback((string url, string fileName) => { _DownloadedCompressedFiles.Add(url.ToUpper(), fileName.ToUpper()); }); _MovedFiles = new Dictionary <string, string>(); _Provider.Setup(r => r.MoveFile(It.IsAny <string>(), It.IsAny <string>())).Callback((string temporaryFileName, string liveFileName) => { _MovedFiles.Add(temporaryFileName.ToUpper(), liveFileName.ToUpper()); }); }
public void TestInitialise() { _OriginalClassFactory = Factory.TakeSnapshot(); _ConfigurationStorage = TestUtilities.CreateMockSingleton<IConfigurationStorage>(); _ConfigurationStorage.Setup(r => r.Folder).Returns(ConfigurationFolder); _StandingDataManager = TestUtilities.CreateMockSingleton<IStandingDataManager>(); _StandingDataManagerLock = new object(); _StandingDataManager.Setup(r => r.Lock).Returns(_StandingDataManagerLock); _Implementation = Factory.Singleton.Resolve<IStandingDataUpdater>(); _Provider = new Mock<IStandingDataUpdaterProvider>(); _Implementation.Provider = _Provider.Object; _FileExists = new Dictionary<string,bool>(); foreach(var fileName in AllFileNames) { _FileExists.Add(fileName, true); } _Provider.Setup(p => p.FileExists(It.IsAny<string>())).Returns((string fileName) => { return _FileExists[fileName.ToUpper()]; }); _ReadLines = new Dictionary<string,List<string>>(); foreach(var fileName in AllFileNames) { _ReadLines.Add(fileName, new List<string>()); } _Provider.Setup(p => p.ReadLines(It.IsAny<string>())).Returns((string fileName) => { return _ReadLines[fileName.ToUpper()].ToArray(); }); _DownloadLines = new Dictionary<string,List<string>>(); foreach(var url in AllUrls) { _DownloadLines.Add(url, new List<string>()); } _Provider.Setup(p => p.DownloadLines(It.IsAny<string>())).Returns((string url) => { return _DownloadLines[url.ToUpper()].ToArray(); }); _SavedLines = new Dictionary<string,List<string>>(); _Provider.Setup(p => p.WriteLines(It.IsAny<string>(), It.IsAny<string[]>())).Callback((string fileName, string[] lines) => { var key = fileName.ToUpper(); var value = new List<string>(lines); _SavedLines.Add(key, value); }); _DownloadedCompressedFiles = new Dictionary<string,string>(); _Provider.Setup(r => r.DownloadAndDecompressFile(It.IsAny<string>(), It.IsAny<string>())).Callback((string url, string fileName) => { _DownloadedCompressedFiles.Add(url.ToUpper(), fileName.ToUpper()); }); _MovedFiles = new Dictionary<string,string>(); _Provider.Setup(r => r.MoveFile(It.IsAny<string>(), It.IsAny<string>())).Callback((string temporaryFileName, string liveFileName) => { _MovedFiles.Add(temporaryFileName.ToUpper(), liveFileName.ToUpper()); }); }
/// <summary> /// Raised when the user clicks the download button on the view. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void View_DownloadButtonClicked(object sender, EventArgs args) { var standingDataManager = Factory.Singleton.ResolveSingleton <IStandingDataManager>(); var busyState = _View.ShowBusy(true, null); try { _View.Status = Strings.DownloadingPleaseWait; IStandingDataUpdater updater = Factory.Singleton.Resolve <IStandingDataUpdater>(); updater.Update(); standingDataManager.Load(); } finally { _View.Status = standingDataManager.RouteStatus; _View.ShowBusy(false, busyState); } }