Exemplo n.º 1
0
        private void DownloadTasks()
        {
            var list = new HtmlFileReader().ReadAllFilesInDirectory(settings.TaskListPath);
            var listOfLinks = new TaskListParser().ParseMultiplePages(list);

            var fileDownloader = new TaskFileDownloader(settings.DownloadPath, new WebClient(), new TaskNameParser());
            fileDownloader.DownlaodFiles(listOfLinks);
        }
        public void ListParserExtractsLinksFromMultipleFiles()
        {
            var list = new HtmlFileReader().ReadAllFilesInDirectory(@"..\..\ListParserIntegrationTests\Lists\");
            var listOfLinks = new TaskListParser().ParseMultiplePages(list);

            var goldFile = File.ReadAllLines(@"..\..\ListParserIntegrationTests\ListParserGoldFile.txt");

            Assert.That(listOfLinks, Is.EqualTo(goldFile));
        }
Exemplo n.º 3
0
        public void TaskListParserParsesMultipleListPages()
        {
            const string page1 = "<tr class=\"row0\"><td><a href=\"result.php?resultid=2459691410\">2459691410</a></td> \n";
            const string page2 = "<tr class=\"row1\"><td><a href=\"result.php?resultid=2459681474\">2459681474</a></td> \n";

            const string expectedString1 = "http://setiathome.berkeley.edu/result.php?resultid=2459691410";
            const string expectedString2 = "http://setiathome.berkeley.edu/result.php?resultid=2459681474";

            var result = new TaskListParser().ParseMultiplePages(new List<string> {page1, page2});
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0], Is.EqualTo(expectedString1));
            Assert.That(result[1], Is.EqualTo(expectedString2));
        }
Exemplo n.º 4
0
        public void TaskListParserFindsAndReturnsTaskPageLink()
        {
            var html = "<td class=\"navbar\"><a class=\"navbar\" href=\"http://setiathome.berkeley.edu/index.php\"><nobr><b>HOME</b></nobr></a></td> \n";
            html += "<tr class=\"row0\"><td><a href=\"result.php?resultid=2459691410\">2459691410</a></td> \n";
            html += "<tr class=\"row1\"><td><a href=\"result.php?resultid=2459681474\">2459681474</a></td> \n";

            const string expectedString1 = "http://setiathome.berkeley.edu/result.php?resultid=2459691410";
            const string expectedString2 = "http://setiathome.berkeley.edu/result.php?resultid=2459681474";

            var result = new TaskListParser().ParsePage(html);
            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0], Is.EqualTo(expectedString1));
            Assert.That(result[1], Is.EqualTo(expectedString2));
        }