public void DownloadFileWithAlternateFromWindowsShare() { // These download URLs need to be changed FileDownloader downloader = new FileDownloader(); // Download them from a windows share. We could get a C# MapDrive() function to allow this portion of the // test not to rely on a hardcoded SAMBA path. if (Directory.Exists(sambaPath)) { foreach (String s in fileSizes.Keys) { string fileUrl = "file:///" + sambaPath + s; List <string> urlList = new List <string>(); urlList.Add("file://somebadpath" + s); urlList.Add(fileUrl); urlList.Add("file://somebadpath" + s); downloader.Download(urlList, OUTPUT_DIRECTORY); string fi = Path.Combine(OUTPUT_DIRECTORY, s); Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(fi, fileSizes[s])); } } else { Assert.Ignore("Test ignored because share is not mapped or may not exist."); } }
public void TestFixtureSetUp() { InstallPadTest.ExtractToFile(DATA_DIRECTORY, "data", ".txt"); InstallPadTest.ExtractToFile(DATA_DIRECTORY, "data", ".zip"); Directory.CreateDirectory(OUTPUT_DIRECTORY); }
public void DownloadHttp() { FileDownloader downloader = new FileDownloader(); foreach (String s in fileSizes.Keys) { downloader.Download(InstallPadTest.GetDownloadPath(s), OUTPUT_DIRECTORY); string fi = Path.Combine(OUTPUT_DIRECTORY, s); // Veryify file exists and is the correct size Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(fi, fileSizes[s])); } }
public void DownloadFile() { FileDownloader downloader = new FileDownloader(); foreach (String s in fileSizes.Keys) { string fileUrl = "file:///" + Path.Combine(DATA_DIRECTORY, s); downloader.Download(fileUrl, OUTPUT_DIRECTORY); string fi = Path.Combine(OUTPUT_DIRECTORY, s); // Veryify file exists and is the correct size Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(fi, fileSizes[s])); } }
public void Cancel() { cancelTestDownloader = new FileDownloader(); cancelTestDownloader.ProgressChanged += new DownloadProgressHandler(Cancel_ProgressChanged); cancelTestDownloader.Download(InstallPadTest.GetDownloadPath("test3.txt"), OUTPUT_DIRECTORY); string fi = Path.Combine(OUTPUT_DIRECTORY, "test3.txt"); // Ensure file exists but is not full, since our block size is 1k and we've only downloaded // one block by this point. Assert.IsTrue(File.Exists(fi)); FileInfo info = new FileInfo(fi); // If block size is 1K, which it is by default, then info.Length should be 1024 Assert.IsTrue(info.Length != 0); Assert.IsTrue(info.Length < fileSizes["test3.txt"]); }
public void DownloadFileWithAlternate() { // These download URLs need to be changed FileDownloader downloader = new FileDownloader(); foreach (String s in fileSizes.Keys) { string fileUrl = "file:///" + Path.Combine(DATA_DIRECTORY, s); List <string> urlList = new List <string>(); urlList.Add("file://somebadpath" + s); urlList.Add(fileUrl); urlList.Add("file://somebadpath" + s); downloader.Download(urlList, OUTPUT_DIRECTORY); // Veryify file exists and is the correct size Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(Path.Combine(OUTPUT_DIRECTORY, s), fileSizes[s])); } }
public void DownloadFileFromWindowsShare() { FileDownloader downloader = new FileDownloader(); // Download them from a windows share. We could get a C# MapDrive() function to allow this portion of the // test not to rely on a hardcoded share path. if (Directory.Exists(sambaPath)) { foreach (String s in fileSizes.Keys) { string fileUrl = "file:///" + sambaPath + s; downloader.Download(fileUrl, OUTPUT_DIRECTORY); string fi = Path.Combine(OUTPUT_DIRECTORY, s); Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(fi, fileSizes[s])); } } else { Assert.Ignore("Test ignored because share is not mapped or may not exist."); } }
public void TestUnZip() { string target = "test4.zip"; string fileUrl = Path.Combine(DATA_DIRECTORY, target); try { InstallPad.Zip.Instance.ExtractZip(fileUrl, OUTPUT_DIRECTORY); } catch (Exception ex) { Console.WriteLine(ex.Message); } foreach (string f in Directory.GetFiles(OUTPUT_DIRECTORY)) { FileInfo fi = new FileInfo(f); FileInfo fr = new FileInfo(Path.Combine(DATA_DIRECTORY, fi.Name)); // Veryify file exists and is the correct size Assert.IsTrue(InstallPadTest.VerifyExistenceAndSize(f, fr.Length)); } }