예제 #1
0
        void MapResult(WebTestResult testResult, CrawlResult crawlRes)
        {
            if (crawlRes == null || testResult == null)
            {
                return;
            }
            int crawledCount;

            crawlRes.CrawlContext.CrawlCountByDomain.TryGetValue(crawlRes.RootUri.Authority, out crawledCount);
            testResult.CrawledPagesCount = crawledCount;
            testResult.TestedPagesCount  = Context.TestedPagesCount;
            testResult.Exception         = crawlRes.ErrorException;
        }
예제 #2
0
        public async Task <WebTestResult> BeginTest(Uri uri)
        {
            Context.TestedPagesCount = 0;
            WebTestResult testResult = new WebTestResult();
            CrawlResult   crawlRes   = null;
            var           stopwatch  = Stopwatch.StartNew();

            try
            {
                crawlRes = await CrawlAndTest(uri).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                testResult.Exception = e;
            }
            finally
            {
                stopwatch.Stop();
                testResult.Elapsed = stopwatch.Elapsed;
            }
            MapResult(testResult, crawlRes);
            return(testResult);
        }