Beispiel #1
0
        public void TestDownloader()
        {
            var zipUrl = "http://www.baidu.com";
//            var zipUrl = "http://dzp79b220mp4w.cloudfront.net/g1-resources-package/trunk/g1.resources.trunk.1.4.0.0.zip"; // very slow, 弱网络
            var downloader = new HttpDownloader(zipUrl, "test_download.html");

            downloader.SetStepCallback(
                (ab) =>
            {
                Console.WriteLine(string.Format("Downloader progress: {0}", downloader.Progress));
            });
            downloader.Start();
            var lastProgress = 0d;

            while (!downloader.IsFinished)
            {
                var progress = downloader.Progress;
                if (!lastProgress.Equals(progress))
                {
                    //		        Assert.True(progress > 0);
                    //		        Assert.True(progress < 1);
//                    Console.WriteLine("Progress: {0}", progress);
                    lastProgress = progress;
                }
                Thread.Sleep(1);
            }

            Assert.False(downloader.IsError);
            Assert.True(File.Exists("test_download.html"));
        }