public async Task ParseTextSitemapAsync_Cancellation() { using (var reader = LoadResource("text-sitemap.txt")) { var parser = new TextSitemapParser(); await Assert.ThrowsExceptionAsync <OperationCanceledException>( async() => await parser.ParseSitemapAsync(reader, new CancellationToken(true)) ); } }
public async Task ParseTextSitemapAsync() { foreach (var culture in CultureInfo.GetCultures(CultureTypes.AllCultures)) { Thread.CurrentThread.CurrentCulture = culture; using (var reader = LoadResource("text-sitemap.txt")) { var parser = new TextSitemapParser(); var sitemapFile = await parser.ParseSitemapAsync(reader); Assert.AreEqual(3, sitemapFile.Urls.Count()); var entry = sitemapFile.Urls.ElementAt(0); Assert.AreEqual(new Uri("http://www.example.com/"), entry.Location); entry = sitemapFile.Urls.ElementAt(1); Assert.AreEqual(new Uri("http://www.example.com/about"), entry.Location); entry = sitemapFile.Urls.ElementAt(2); Assert.AreEqual(new Uri("http://www.example.com/contact-us"), entry.Location); } } }