static void Main(string[] args) { //the link to crawl and the empty list to store all the crawled links string testlink = "https://www.ksl.com/"; List <string> testList = new List <string>(); //create the crawler DHCrawler testCrawler = new DHCrawler(testList, testlink); testCrawler.Crawl(testlink); //testCrawler.printAllLink(); //test if the crawler get any data //create a database connection for crawler CrawlerAppConsoleDatabaseConnection crawlerDatabase = new CrawlerAppConsoleDatabaseConnection(testCrawler._pagesVisited, testCrawler._pagesToVisit); /* * these lines are used for testing if DataStore gets same value of the the Console App */ //System.Console.WriteLine("Links in database"); //crawlerDatabase.printAllLinkOfDatabase(); //input links from Crawler to Database if (crawlerDatabase.TestDatabaseConnection() == 1) { crawlerDatabase.InsertDataToDatabase(); } ////testing purpose //crawlerDatabase.printAllLinkOfDatabase(); System.Console.WriteLine("Successfully crawl and end crawling now"); System.Console.ReadKey(); }
public void TestEstablishDatabaseConnection() { // Arrange List <string> _pagesVisited = new List <string>(); //store all the links Crawler reached _pagesVisited.Add("www.visited1.com"); _pagesVisited.Add("www.visited2.com"); List <string> _pagesToVisit = new List <string>(); //store all the links Crawler has not reached _pagesToVisit.Add("www.TOvisited1.com"); _pagesToVisit.Add("www.TOvisited2.com"); _pagesToVisit.Add("www.TOvisited3.com"); // Act CrawlerAppConsoleDatabaseConnection crawlerDatabase = new CrawlerAppConsoleDatabaseConnection(_pagesVisited, _pagesToVisit); // Assert Assert.AreEqual(crawlerDatabase.TestDatabaseConnection(), 1); }