Skip to content

Commit

Permalink
#88 add test scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
totpero committed Dec 3, 2024
1 parent b91a252 commit 9ed9ae9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions DeviceDetector.NET.Tests/DeviceDetectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DeviceDetectorNET.Results.Client;
using Xunit;

namespace DeviceDetectorNET.Tests;
Expand Down Expand Up @@ -788,4 +789,39 @@ public void TestIssue22_Test3()
dd.Match.OsFamily.Should().Be("Mac");
dd.Match.DeviceType.Should().Be("desktop");
}

/// <summary>
/// Issue #88
/// </summary>
[Fact]
public void TestIssue88_Test1()
{
const string userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
var dd = DeviceDetector.GetInfoFromUserAgent(userAgent);
dd.Success.Should().BeTrue();
var browserMatch = dd.Match.Client as BrowserMatchResult;
browserMatch.Should().Be("Chrome");
browserMatch.Should().Be("131.0.0.0");
browserMatch.EngineVersion.Should().Be("Blink");

}
/// <summary>
/// Issue #88
/// </summary>
[Fact]
public void TestIssue88_Test2()
{
var clientHints = ClientHints.Factory(new Dictionary<string, string>
{
["sec-ch-ua"] = "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
});
const string userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36";
var dd = DeviceDetector.GetInfoFromUserAgent(userAgent, clientHints);
dd.Success.Should().BeTrue();
var browserMatch = dd.Match.Client as BrowserMatchResult;
browserMatch.Should().Be("360 Secure Browser");
browserMatch.Should().Be("131.0.0.0");
browserMatch.EngineVersion.Should().Be("Blink");

}
}
2 changes: 1 addition & 1 deletion DeviceDetector.NET/DeviceDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ protected void ParseDevice()
osVersion = os.Match.Version;
if (!string.IsNullOrEmpty(osVersion))
{
osVersion = !osVersion.Contains(".") ? osVersion + ".0" : osVersion;
osVersion = !osVersion.Contains('.') ? osVersion + ".0" : osVersion;
}
}

Expand Down

0 comments on commit 9ed9ae9

Please sign in to comment.