public void Test() { var httpClient = GetMockHttpClient("http://scottbm.me/sitemap.xml", @"<?xml version=""1.0"" encoding=""UTF-8""?> <urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9""> <url> <loc>http://scottbm.me/</loc> <lastmod>2017-09-01</lastmod> <changefreq>weekly</changefreq> <priority>0.5</priority> </url></urlset>"); var retriever = new SitemapRetriever(httpClient); var sitemap = retriever.Retrieve("http://scottbm.me/sitemap.xml"); Assert.Single(sitemap.Urls); }
public void Process(int sitemapSubmissionId) { var sitemapSubmission = _db.SitemapSubmissions.Single(x => x.Id == sitemapSubmissionId); // _hubContext.Clients.Groups(sitemapSubmissionId.ToString()).SendAsync("SubmissionUpdate", "from hangfire"); var progressUpdater = new SignalRProgressUpdater(_hubContext, sitemapSubmissionId.ToString()); using (var client = new HttpClient()) { var validator = new SitemapValidator.Core.SitemapValidator(client, progressUpdater); var retriever = new SitemapRetriever(client); var sitemap = retriever.Retrieve(sitemapSubmission.Url); validator.Validate(sitemap, new Options { ExpectedStatusCode = 200, Delay = 1000 }); } }