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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of <see cref="HttpUserAgentInformation"/>
 /// </summary>
 private HttpUserAgentInformation(string userAgent, HttpUserAgentPlatformInformation?platform, HttpUserAgentType type, string?name, string?version, string?deviceName)
 {
     UserAgent        = userAgent;
     Type             = type;
     Name             = name;
     Platform         = platform;
     Version          = version;
     MobileDeviceType = deviceName;
 }
 public void TestValue(HttpUserAgentType type, byte value)
 {
     ((byte)type == value).Should().Be(true);
 }