public void Initialize() { tester = new TesterIOConsole(); transport = new Mock <ITransport>(); config = new Mock <Config>(true, null); fileSystem = new Mock <IFileSystem>(); cache = new Mock <ICache>(); downloader = new DownloaderFile(tester.Mock(), config.Object, transport.Object, null, cache.Object, fileSystem.Object); config.Setup((o) => o.Get(It.IsIn(Settings.VendorDir), ConfigOptions.None)) .Returns($"/vendor"); }
public void DownFileSync_file_exists_yes() { IO.FileInfo downloadedFile = new IO.FileInfo("C:\\temp\\Download\\" + Constants.Ftp.Files.File_1_1.Name); DownloaderFile df = new DownloaderFile(Constants.Ftp.Files.File_1_1, downloadedFile); df.StartDownload(async: false); downloadedFile.Refresh(); byte[] file_ftp = IO.File.ReadAllBytes(Constants.HDFtp.Files.File_1_1.FullName); byte[] file_hd = IO.File.ReadAllBytes(downloadedFile.FullName); Assert.IsTrue(downloadedFile.Exists); Assert.IsTrue(StructuralComparisons.StructuralEqualityComparer.Equals(file_ftp, file_hd)); }
public void DownFileSync_file_exists_no() { IO.FileInfo downloadedFile = new IO.FileInfo("C:\\temp\\download\\" + Constants.Ftp.Files.NotExists.Name); DownloaderFile df = new DownloaderFile(Constants.Ftp.Files.NotExists, downloadedFile); try { df.StartDownload(async: false); Assert.IsTrue(false); } catch (Exception e) { Assert.IsTrue(e is System.Net.WebException); Assert.IsTrue(true); } }