Ejemplo n.º 1
0
        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]));
            }
        }
Ejemplo n.º 2
0
        public void DownloadFtp()
        {
            FileInfo info;
            
            // We expect no exceptions
            downloadFtpTestDownloader = new FileDownloader();
            downloadFtpTestDownloader.ProgressChanged += new DownloadProgressHandler(DownloadFtp_ProgressChanged);
            downloadFtpTestDownloader.Download(firefoxFtpUrl, OUTPUT_DIRECTORY);

            string fi = Path.Combine(OUTPUT_DIRECTORY, Path.GetFileName(new Uri(firefoxFtpUrl).ToString()));

            // Ensure the file size is 1KB, meaning we were notified of progress information
            // and Cancel worked.
            info = new FileInfo(fi);
            Assert.AreEqual(info.Length, 1024);

            // Trying (and failing) to resume an ftp source should result
            // in the file getting deleted and starting over at 0 KB.
            downloadFtpTestDownloader.Download(firefoxFtpUrl, OUTPUT_DIRECTORY);
            info = new FileInfo(fi);
            Assert.AreEqual(info.Length, 1024);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize this with the information from an ApplicationItem
        /// </summary>
        /// <param name="application"></param>
        public ApplicationListItem(ApplicationItem application)
            : this()
        {
            this.ApplicationItem = application;
            this.Controls.Add(downloadErrorBox);
            AddErrorBoxes();

            downloader = new FileDownloader();
            ProxyOptions options = InstallPadApp.AppList.InstallationOptions.ProxyOptions;
            if (options != null)
                downloader.Proxy = options.ProxyFromOptions();

            downloader.ProgressChanged += new DownloadProgressHandler(downloader_ProgressChanged);
            downloader.DownloadComplete += new EventHandler(downloader_DownloadComplete);

            this.Checked = this.ApplicationItem.Options.CheckedByDefault;
            this.labelName.MouseClick += new MouseEventHandler(labelName_MouseClick);
        }
Ejemplo n.º 4
0
        public void MalformedUrl()
        {
            // We expect some kind of descriptive argument exception when we give a malformed url
            FileDownloader downloader = new FileDownloader();
            ArgumentException ex=null;

            try
            {
                downloader.Download(malformedUrl, OUTPUT_DIRECTORY);
            }
            catch (ArgumentException e)
            {
                ex = e;
            }
            finally
            {
                Assert.IsNotNull(ex);
            }

        }
Ejemplo n.º 5
0
        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"]);
        }
Ejemplo n.º 6
0
        public void BadUrls()
        {
            FileDownloader downloader = new FileDownloader();

            foreach (String badUrl in badUrls)
            {
                System.Net.WebException webException = null;
                try
                {
                    downloader.Download(badUrl, OUTPUT_DIRECTORY);
                }
                catch (System.Net.WebException e)
                {
                    webException = e;
                }

                finally
                {
                    Assert.IsNotNull(webException);
                }
            }
        }
Ejemplo n.º 7
0
        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.");
            }
        }
Ejemplo n.º 8
0
        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]));
            }
        }
Ejemplo n.º 9
0
        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.");
            }
        }
Ejemplo n.º 10
0
        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]));
            }
        }