public void SetUp() { _fakeHyperLinkParser = new Mock<IHyperLinkParser>(); _fakeHttpRequester = new Mock<IPageRequester>(); _fakeCrawlDecisionMaker = new Mock<ICrawlDecisionMaker>(); _fakeMemoryManager = new Mock<IMemoryManager>(); _fakeDomainRateLimiter = new Mock<IDomainRateLimiter>(); _fakeRobotsDotTextFinder = new Mock<IRobotsDotTextFinder>(); _dummyScheduler = new FifoScheduler(); _dummyThreadManager = new ProducerConsumerThreadManager(10); _dummyConfiguration = new CrawlConfiguration(); _dummyConfiguration.ConfigurationExtensions.Add("somekey", "someval"); _unitUnderTest = new PoliteWebCrawler(_dummyConfiguration, _fakeCrawlDecisionMaker.Object, _dummyThreadManager, _dummyScheduler, _fakeHttpRequester.Object, _fakeHyperLinkParser.Object, _fakeMemoryManager.Object, _fakeDomainRateLimiter.Object, _fakeRobotsDotTextFinder.Object); _unitUnderTest.CrawlBag.SomeVal = "SomeVal"; _unitUnderTest.CrawlBag.SomeList = new List<string>() { "a", "b" }; _rootUri = new Uri("http://a.com/"); }
public void SetUp() { _fakeHyperLinkParser = new Mock<IHyperLinkParser>(); _fakeHttpRequester = new Mock<IPageRequester>(); _fakeCrawlDecisionMaker = new Mock<ICrawlDecisionMaker>(); _fakeDomainRateLimiter = new Mock<IDomainRateLimiter>(); _fakeMemoryManager = new Mock<IMemoryManager>(); _fakeRobotsDotTextFinder = new Mock<IRobotsDotTextFinder>(); _fakeRobotsDotText = new Mock<IRobotsDotText>(); _dummyScheduler = new FifoScheduler(); _dummyThreadManager = new ProducerConsumerThreadManager(1); _dummyConfiguration = new CrawlConfiguration(); _dummyConfiguration.ConfigurationExtensions.Add("somekey", "someval"); _rootUri = new Uri("http://a.com/"); }
public void Crawl_SingleThread_ExceptionThrownDuringProcessPage_SetsCrawlResultError() { _dummyThreadManager = new ProducerConsumerThreadManager(1); _unitUnderTest = new PoliteWebCrawler(_dummyConfiguration, _fakeCrawlDecisionMaker.Object, _dummyThreadManager, _dummyScheduler, _fakeHttpRequester.Object, _fakeHyperLinkParser.Object, _fakeMemoryManager.Object, _fakeDomainRateLimiter.Object, _fakeRobotsDotTextFinder.Object); Exception ex = new Exception("oh no"); _fakeCrawlDecisionMaker.Setup(f => f.ShouldCrawlPage(It.IsAny<PageToCrawl>(), It.IsAny<CrawlContext>())).Throws(ex); CrawlResult result = _unitUnderTest.Crawl(_rootUri); _fakeCrawlDecisionMaker.Verify(f => f.ShouldCrawlPage(It.IsAny<PageToCrawl>(), It.IsAny<CrawlContext>()), Times.Exactly(1)); Assert.IsTrue(result.ErrorOccurred); Assert.AreSame(ex, result.ErrorException); }