public void TestParseNoBot() { var botParser = new BotParser(); botParser.SetUserAgent("Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; SV1; SE 2.x)"); var result = botParser.Parse(); result.Success.Should().BeFalse(); }
public void TestParseNoDetails() { var botParser = new BotParser(); botParser.SetUserAgent("Googlebot/2.1 (http://www.googlebot.com/bot.html)"); var result = botParser.Parse(); result.Success.Should().BeTrue(); }
/// <summary> /// Parses the UA for bot information using the Bot parser /// </summary> private void ParseBot() { if (skipBotDetection) { bot = new ParseResult <BotMatchResult>(); return; } var botParser = new BotParser(); botParser.SetUserAgent(userAgent); botParser.SetCache(cache); botParser.DiscardDetails = discardBotInformation; bot = botParser.Parse(); }
public void TestGetInfoFromUaBot() { var expected = new Bot { Name = "Googlebot", Category = "Search bot", Url = "http://www.google.com/bot.html", Producer = new Producer { Name = "Google Inc.", Url = "http://www.google.com" } }; var botParser = new BotParser { DiscardDetails = false }; botParser.SetUserAgent("Googlebot/2.1 (http://www.googlebot.com/bot.html)"); var result = botParser.Parse(); result.Match.Should().BeEquivalentTo(expected, config => config.ExcludingMissingMembers()); }