public void DownloadPageTest() { DownloaderThroughTor downloader = new DownloaderThroughTor(); HtmlDocument actual = null; actual = downloader.Page(ParserRutor.UriSoft); Assert.IsNotNull(actual); StringAssert.Contains(actual.ParsedText, @"<meta http-equiv=""content-type"" content=""text/html; charset=utf-8"" />"); StringAssert.Contains(actual.ParsedText, @"<link rel=""shortcut icon"" href=""/s/favicon.ico"" />"); StringAssert.Contains(actual.ParsedText, @"<title>зеркало rutor.info :: Софт</title>"); StringAssert.Contains(actual.ParsedText, @"Файлы для обмена предоставлены пользователями сайта. Администрация не несёт ответственности за их содержание."); StringAssert.Contains(actual.ParsedText, @"На сервере хранятся только торрент-файлы. Это значит, что мы не храним никаких нелегальных материалов. <a href=""/advertise.php"">Реклама</a>. "); }
private void SetTorrentFile(ReadyPost readyPost) { string today = DateTime.Today.ToShortDateString(); string folderName = Environment.CurrentDirectory + $"\\storage\\{today}"; Directory.CreateDirectory(folderName); string fileName = GetSafeFilename(readyPost.Name); DownloaderThroughTor downloader = new DownloaderThroughTor(); Uri uriFile = new Uri(ParserRutor.Main.OriginalString + readyPost.TorrentUrl); downloader.FinishedDownoadFile += Downloader_FinishedDownoadFile; downloader.FileAsync(uriFile, $"{folderName}\\{fileName}.torrent"); BrowserPostReady.TorrentFile = $"{folderName}\\{fileName}.torrent"; }
public void StartDownloadTest() { DownloaderThroughTor downloader = new DownloaderThroughTor(); HtmlDocument actual = null; bool eventCall = false; downloader.FinishDownload += delegate(object s, DownloaderHtmlPageArgs e) { actual = e.Page; eventCall = true; }; downloader.StartDownloadAsync(ParserRutor.UriSoft); CommonFunction.SleepTimer(12, ref eventCall); Assert.IsNotNull(actual); }