public void CanAddMultipleBeforeAndAfterDecorators() { bool one = false, two = false, three = false, four = false; LinkCheck .On(x => x.Html("<a href=\"http://www.google.com\">Link</a>")) .OnRequest(x => { one = true; }) .OnRequest(x => { two = true; }) .OnResponse(x => { three = true; }) .OnResponse(x => { four = true; }) .Start(); Assert.That(one); Assert.That(two); Assert.That(three); Assert.That(four); }
public void CanCheckWithMinimumConfiguration() { var result = LinkCheck .On(x => x.Html("<a href=\"http://www.google.com\">Google</a>")) .Start(); Assert.That(result != null); }
public void CanCheckOnUrlWithRelativesAutomatically() { var result = LinkCheck .On(x => x.Url(new Uri("http://www.google.com"))) .Start(); Assert.That(result != null); Assert.That(result.Any(x => x.Url.IsAbsoluteUri)); Assert.That(result.Any(x => !x.Url.IsAbsoluteUri)); }
public void CanCheckBothAbsoluteAndRelativeUrls() { var result = LinkCheck .On(x => x .Html("<a href=\"/relative/url\">Relative</a><a href=\"http://absolute.url\">Absolute</a>") .RelativeOrAbsolute(new Uri("http://www.google.com"))) .Start(); Assert.That(result != null); Assert.That(result.Count, Is.EqualTo(2)); }
public void DoNotRequireBaseUrlWhenCheckRelativesOnUrl() { var result = LinkCheck .On(x => x .Url(new Uri("http://www.google.com")) .Relative()) .Start(); Assert.That(result != null); Assert.That(result.Any()); }
public void CanCheckRelativeUrls() { var result = LinkCheck .On(x => x .Html("<a href=\"/some/relative/url.html\">Relative</a>") .Relative(new Uri("http://www.google.com"))) .Start(); Assert.That(result != null); Assert.That(result.Any()); }
public void CanFindErrors() { var result = LinkCheck .On(x => x.Html("<a href=\"http://unknownhost42.unk/unknown\">Unknown</a>")) .Start(); Assert.That(result != null); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result.First().Url.ToString(), Is.EqualTo("http://unknownhost42.unk/unknown")); Assert.That(result.First().StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); }
public void OnCheckAbsolutesWhenSpecified() { var result = LinkCheck .On( x => x.Html("<a href=\"/relative/url\">Relative</a><a href=\"http://www.google.com\">Absolute</a>") .Absolute()) .Start(); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result.First().Url.IsAbsoluteUri); }
public void CanCheckWithBeforeAndAfterDecorators() { var result = LinkCheck .On(x => x.Html("<a href=\"http://www.google.com\">Google</a>")) .AsBot(x => x.Bing()) .OnRequest(x => x.Headers.Add("X-From", "*****@*****.**")) .OnResponse(x => Assert.That(x != null)) .Start(); Assert.That(result != null); Assert.That(result.Count, Is.EqualTo(1)); Assert.That(result.All(x => x.StatusCode == HttpStatusCode.OK)); }
public bool TestLinksOnWebPagesUsingFluentLinkChecker(string uri) { var result = LinkCheck .On(src => src.Url(new Uri(uri)) .Relative()) .AsBot(bot => bot.Bing()) .Start(); foreach (var link in result) { Console.WriteLine("Tested Url: {0}, Status Code: {1}", link.Url, link.StatusCode); if (link.StatusCode != HttpStatusCode.OK) { return(false); } } // All status codes returned are OK return(true); }
public bool TestLinksOnWebPage(string url) { _testOutputHelper.WriteLine("Testing for broken links on web page '{0}'...", url); var uri = new Uri(url); var result = LinkCheck .On(src => src.Url(uri).Relative()) .AsBot(bot => bot.Bing()) .Start(); foreach (var link in result) { _testOutputHelper.WriteLine(" Tested link to URL '{0}': Status Code = {1}", link.Url, link.StatusCode); if (link.StatusCode != HttpStatusCode.OK) { return(false); } } // All status codes returned are OK return(true); }