HasWindows10() public static method

Determines if the User Agent String indicates Windows 8
public static HasWindows10 ( string userAgent ) : bool
userAgent string A User Agent String
return bool
        public void CheckWindows10Detection()
        {
            // User agent from Edge (Windows 10 build 10074)
            var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0";

            Assert.IsTrue(Helpers.HasWindows10(userAgent), "Windows 10 detection failed");

            // User agent from IE11 (Windows 10 build 10074)
            userAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; MALCJS; rv:11.0) like Gecko";

            Assert.IsTrue(Helpers.HasWindows10(userAgent), "Windows 10 detection failed");
            Assert.IsFalse(Helpers.HasWindows8(userAgent), "Windows 8 incorrectly detected");
        }
        public void CheckWindows10Shows46()
        {
            // Arrange
            const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0";


            // Act
            string message = Helpers.GetUpdateInformation(UserAgent).Text;

            // Assert
            Assert.IsTrue(Helpers.HasWindows10(UserAgent), "Windows 10 detection failed");
            StringAssert.Contains(message, "4.6", "Windows 10 must have at least 4.6");
        }
示例#3
0
    /// <summary>
    /// Gets a message for the Windows 8 OS.
    /// </summary>
    /// <param name="userAgent">The user agent.</param>
    /// <param name="userMessage">The user message.</param>
    /// <returns>True if the user agent has </returns>
    private static bool GetWindows8Or10Message(string userAgent, ref string userMessage)
    {
        bool hasWindows10 = Helpers.HasWindows10(userAgent);

        if (Helpers.HasWindows8(userAgent) || hasWindows10)
        {
            var version = hasWindows10 ? "4.6" : "4.5";
            userMessage += string.Format(Constants.InferredText, version);
            return(true);
        }

        return(false);
    }