Beispiel #1
0
        public void DownLoaderTest_AggregateException()
        {
            var spiderMock = MockFactory.GetISpiderMock();
            var requstMock = MockFactory.GetRequstMock("http://www.google.com");
            var downLoader = new HttpDownLoader();

            downLoader.DownLoader(requstMock.Object, spiderMock.Object);
        }
Beispiel #2
0
 public Spider(Site site, IPageProcessor pageProcessor)
 {
     Status             = SpiderStatusEnum.Init;
     PageProcessor      = pageProcessor;
     PageProcessor.Site = Site = site;
     Scheduler          = new MemoryScheduler();
     DownLoader         = new HttpDownLoader();
 }
Beispiel #3
0
        public void DownLoaderTest_Success()
        {
            var spiderMock = MockFactory.GetISpiderMock();
            var requstMock = MockFactory.GetRequstMock("http://www.baidu.com");
            var downLoader = new HttpDownLoader();
            var actual     = downLoader.DownLoader(requstMock.Object, spiderMock.Object);

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.StatusCode, 200);
            Assert.AreEqual(actual.Url, requstMock.Object.Uri.ToString());
            Assert.IsTrue(!string.IsNullOrWhiteSpace(actual.Title));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(actual.Content));
        }
Beispiel #4
0
 ///// <summary>
 ///// 下载部分资源包;
 ///// </summary>
 //private void DownPartPackage()
 //{
 //    Uri uri = new Uri(@"http://" + this.updateModel.ServerHost + ":" + this.updateModel.Port + "/Package/" + this.updateModel.Platform + "/" + this.updateModel.Channel + "/" + this.updateModel.LocalVersion.ResVersion + "_" + this.updateModel.ServerVersion.ResVersion + "/package.zip");
 //    this.StartUpdatePackage(uri);
 //}
 ///// <summary>
 ///// 下载完整资源包;
 ///// </summary>
 //private void DownAllPackage()
 //{
 //    Uri uri = new Uri(@"http://" + this.updateModel.ServerHost + ":" + this.updateModel.Port + "/Package/" + this.updateModel.Platform + "/" + this.updateModel.Channel + "/apackage.zip");
 //    this.StartUpdatePackage(uri);
 //}
 /// <summary>
 /// 开始下载资源包;
 /// </summary>
 private void StartUpdatePackage(Uri uri)
 {
     this.updateModel.ServerHost = uri.Host;
     this.updateModel.Port       = uri.Port;
     this.updateModel.HeadHost   = this.updateModel.ServerHost;
     if (uri.Port != 80)
     {
         this.updateModel.HeadHost += ":" + uri.Port;
     }
     AbsolutePath = uri.AbsolutePath;
     SaveZippath  = this.updateModel.LocalResPathRoot + "update/package.zip";
     HttpDownLoader httpDownLoader = HttpDownLoader.instance;
 }
Beispiel #5
0
 void Awake()
 {
     savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "TestDownLoad");
     Timer.IntializeDriver();
     Loom.Initialize();
     DownLoader = new HttpDownLoader();
     DownLoader.OnDownLoadCompleted.AddListener(() =>
     {
         this.finish.text = "下载完成!";
     });
     DownLoader.OnDownLoadUpdate.AddListener(v =>
     {
         this.update.text = string.Format("下载进度:{0} %", (v * 100).ToString("f2"));
     });
 }