public void IsType(string userAgent, HttpUserAgentType expectedType, bool isMobile) { HttpUserAgentInformation info = HttpUserAgentInformation.Parse(userAgent); if (expectedType == HttpUserAgentType.Browser) { info.IsType(HttpUserAgentType.Browser).Should().Be(true); info.IsType(HttpUserAgentType.Robot).Should().Be(false); info.IsType(HttpUserAgentType.Unknown).Should().Be(false); info.IsBrowser().Should().Be(true); info.IsRobot().Should().Be(false); } else if (expectedType == HttpUserAgentType.Robot) { info.IsType(HttpUserAgentType.Browser).Should().Be(false); info.IsType(HttpUserAgentType.Robot).Should().Be(true); info.IsType(HttpUserAgentType.Unknown).Should().Be(false); info.IsBrowser().Should().Be(false); info.IsRobot().Should().Be(true); } else if (expectedType == HttpUserAgentType.Unknown) { info.IsType(HttpUserAgentType.Browser).Should().Be(false); info.IsType(HttpUserAgentType.Robot).Should().Be(false); info.IsType(HttpUserAgentType.Unknown).Should().Be(true); info.IsBrowser().Should().Be(false); info.IsRobot().Should().Be(false); } info.IsMobile().Should().Be(isMobile); }
public void BotTests(string ua, string name) { HttpUserAgentInformation uaInfo = HttpUserAgentInformation.Parse(ua); uaInfo.Name.Should().Be(name); uaInfo.Version.Should().Be(null); uaInfo.UserAgent.Should().Be(ua); uaInfo.Type.Should().Be(HttpUserAgentType.Robot); uaInfo.Platform.Should().Be(null); uaInfo.MobileDeviceType.Should().Be(null); uaInfo.IsBrowser().Should().Be(false); uaInfo.IsMobile().Should().Be(false); uaInfo.IsRobot().Should().Be(true); }
public void BrowserTests(string ua, string name, string version, string platformName, HttpUserAgentPlatformType platformType, string mobileDeviceType) { HttpUserAgentInformation uaInfo = HttpUserAgentInformation.Parse(ua); uaInfo.Name.Should().Be(name); uaInfo.Version.Should().Be(version); uaInfo.UserAgent.Should().Be(ua); uaInfo.Type.Should().Be(HttpUserAgentType.Browser); HttpUserAgentPlatformInformation platform = uaInfo.Platform.GetValueOrDefault(); platform.PlatformType.Should().Be(platformType); platform.Name.Should().Be(platformName); uaInfo.MobileDeviceType.Should().Be(mobileDeviceType); uaInfo.IsBrowser().Should().Be(true); uaInfo.IsMobile().Should().Be(mobileDeviceType is not null); uaInfo.IsRobot().Should().Be(false); }