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); }
public Spider(Site site, IPageProcessor pageProcessor) { Status = SpiderStatusEnum.Init; PageProcessor = pageProcessor; PageProcessor.Site = Site = site; Scheduler = new MemoryScheduler(); DownLoader = new HttpDownLoader(); }
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)); }
///// <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; }
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")); }); }