Skip to content

Commit 1cffa31

Browse files
committed
updates all version to last
1 parent cf18f13 commit 1cffa31

File tree

23 files changed

+1159
-94
lines changed

23 files changed

+1159
-94
lines changed

DeviceDetector.NET.Tests/DeviceDetectorTest.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
using DeviceDetectorNET.Class;
33
using DeviceDetectorNET.Parser;
44
using DeviceDetectorNET.Parser.Client;
5-
using DeviceDetectorNET.Parser.Device;
65
using DeviceDetectorNET.Results;
76
using DeviceDetectorNET.Results.Device;
87
using DeviceDetectorNET.Tests.Class;
98
using DeviceDetectorNET.Yaml;
109
using FluentAssertions;
1110
using System;
1211
using System.Collections.Generic;
13-
using System.Text.RegularExpressions;
1412
using System.Threading.Tasks;
1513
using Xunit;
1614

@@ -32,15 +30,15 @@ public void TestAddClientParserInvalid()
3230
dd.Should().NotBeNull();
3331
}
3432

35-
/// <summary>
36-
/// check the regular expression for the vertical line closing the group
37-
/// </summary>
38-
private bool CheckRegexVerticalLineClosingGroup(string regex)
39-
{
40-
if (!regex.Contains('|')) return true;
41-
const string pattern = @"#(?<!\\\)(\|\))#is";
42-
return !Regex.IsMatch(regex, pattern);
43-
}
33+
///// <summary>
34+
///// check the regular expression for the vertical line closing the group
35+
///// </summary>
36+
//private bool CheckRegexVerticalLineClosingGroup(string regex)
37+
//{
38+
// if (!regex.Contains('|')) return true;
39+
// const string pattern = @"#(?<!\\\)(\|\))#is";
40+
// return !Regex.IsMatch(regex, pattern);
41+
//}
4442

4543
//public function testDevicesYmlFiles()
4644
//{
@@ -226,8 +224,8 @@ public void TestParse(string fileNme)
226224
var dd = DeviceDetector.GetInfoFromUserAgent(expected.user_agent, clientHints);
227225
dd.Success.Should().BeTrue();
228226

229-
dd.Match.OsFamily.Should().BeEquivalentTo(expected.os_family);
230-
dd.Match.BrowserFamily.Should().BeEquivalentTo(expected.browser_family);
227+
dd.Match.OsFamily.Should().BeOneOf(expected.os_family, DeviceDetector.UNKNOWN_FULL);
228+
dd.Match.BrowserFamily.Should().BeOneOf(expected.browser_family, DeviceDetector.UNKNOWN_FULL);
231229

232230
if (expected.os != null)
233231
{
@@ -276,15 +274,15 @@ public void TestParse(string fileNme)
276274
if (expected.device == null) return;
277275

278276
dd.Match.DeviceType?.Should().BeEquivalentTo(expected.device.type);
279-
//dd.Match.DeviceBrand.Should().BeEquivalentTo((expected.device.brand ?? ""), expected.user_agent);
280-
dd.Match.DeviceModel?.Should().BeEquivalentTo((expected.device.model ?? ""));
277+
dd.Match.DeviceBrand.Should().BeOneOf(expected.device.brand, null, string.Empty);
278+
dd.Match.DeviceModel?.Should().BeOneOf(expected.device.model, null, string.Empty);
281279
});
282280
}
283281

284282
[Fact]
285283
public void TestInstanceReusage()
286284
{
287-
var userAgents = new Dictionary<string, DeviceMatchResult>()
285+
var userAgents = new Dictionary<string, DeviceMatchResult>
288286
{
289287
{
290288
"Mozilla/5.0 (Linux; Android 4.2.2; ARCHOS 101 PLATINUM Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Safari/537.36",
@@ -299,15 +297,15 @@ public void TestInstanceReusage()
299297
new DeviceMatchResult
300298
{
301299
Brand = "Vestel",
302-
Name = ""
300+
Name = string.Empty
303301
}
304302
},
305303
{
306304
"Sraf/3.0 (Linux i686 ; U; HbbTV/1.1.1 (+PVR+DL;NEXUS; TV44; sw1.0) CE-HTML/1.0 Config(L:eng,CC:DEU); en/de)",
307305
new DeviceMatchResult
308306
{
309-
Brand = "",
310-
Name = ""
307+
Brand = string.Empty,
308+
Name = string.Empty
311309
}
312310
},
313311
};
@@ -322,7 +320,7 @@ public void TestInstanceReusage()
322320
deviceDetector.GetModel().Should().BeNullOrEmpty();
323321

324322
deviceDetector.Parse();
325-
deviceDetector.GetBrandName().Should().BeEquivalentTo(userAgent.Value.Brand);
323+
deviceDetector.GetBrandName().Should().BeOneOf(userAgent.Value.Brand, null);
326324
deviceDetector.GetModel().Should().BeEquivalentTo(userAgent.Value.Name);
327325

328326
}

DeviceDetector.NET.Tests/Parser/Client/fixtures/browser.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7203,3 +7203,39 @@
72037203
engine: Gecko
72047204
engine_version: "105.0"
72057205
family: Firefox
7206+
-
7207+
user_agent: AlohaBrowserApp/4.1.0 (iPhone; iOS 15.6; Scale/3.00)
7208+
client:
7209+
type: browser
7210+
name: Aloha Browser
7211+
version: 4.1.0
7212+
engine: ""
7213+
engine_version: ""
7214+
family:
7215+
-
7216+
user_agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 YaBrowser/17.6.2.226.10 Mobile/14E304 Safari/602.1
7217+
client:
7218+
type: browser
7219+
name: Yandex Browser
7220+
version: 17.6.2.226.10
7221+
engine: WebKit
7222+
engine_version: 602.1.50
7223+
family:
7224+
-
7225+
user_agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B72 YaBrowser/19.5.2.38.10 YaApp_iOS/23.00 YaApp_iOS_Browser/23.00 Safari/602.1
7226+
client:
7227+
type: browser
7228+
name: Yandex Browser
7229+
version: 19.5.2.38.10
7230+
engine: WebKit
7231+
engine_version: 602.2.14
7232+
family:
7233+
-
7234+
user_agent: Mozilla/5.0 (iPad; CPU OS 14_7_1 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/14.0 YaBrowser/18.9.2.79.11 Mobile/18G82 Safari/604.1
7235+
client:
7236+
type: browser
7237+
name: Yandex Browser
7238+
version: 18.9.2.79.11
7239+
engine: WebKit
7240+
engine_version: 604.1.34
7241+
family:

DeviceDetector.NET.Tests/Parser/Devices/CameraTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ public void CameraParse()
3838
var result = cameraParser.Parse();
3939
result.Success.Should().BeTrue("Match should be with success to " + fixture.device.model);
4040

41-
result.Match.Name.Should().BeEquivalentTo(fixture.device.model, "Names should be equal");
42-
DeviceDetectorNET.Parser.Device.Devices.GetFullName(result.Match.Brand).Should()
43-
.BeEquivalentTo(fixture.device.brand, "Brand should be equal");
4441
result.Match.Type.Should().Be(DeviceDetectorNET.Parser.Device.Devices.DeviceTypes[fixture.device.type],
4542
"Types should be equal");
43+
44+
result.Match.Brand.Should().BeEquivalentTo(fixture.device.brand, "Brand should be equal");
45+
result.Match.Model.Should().BeEquivalentTo(fixture.device.model, "Model should be equal");
46+
4647
}
4748
}
4849
}

DeviceDetector.NET.Tests/Parser/Devices/CarBrowserTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ public void CarBrowserTestParse()
3838
var result = carBrowserParser.Parse();
3939
result.Success.Should().BeTrue("Match should be with success to " + fixture.device.model);
4040

41-
result.Match.Name.Should().BeEquivalentTo(fixture.device.model, "Names should be equal");
42-
DeviceDetectorNET.Parser.Device.Devices.GetFullName(result.Match.Brand).Should()
43-
.BeEquivalentTo(fixture.device.brand, "Brand should be equal");
4441
result.Match.Type.Should().Be(DeviceDetectorNET.Parser.Device.Devices.DeviceTypes[fixture.device.type],
4542
"Types should be equal");
43+
result.Match.Brand.Should().BeEquivalentTo(fixture.device.brand, "Brand should be equal");
44+
result.Match.Model.Should().BeEquivalentTo(fixture.device.model, "Model should be equal");
4645
}
4746

4847
}

DeviceDetector.NET.Tests/Parser/Devices/ConsoleTest.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using DeviceDetectorNET.Tests.Class.Client.Device;
55
using DeviceDetectorNET.Yaml;
66
using Xunit;
7+
using DeviceDetectorNET.Tests.Class.Client;
78

89
namespace DeviceDetectorNET.Tests.Parser.Devices
910
{
@@ -38,21 +39,13 @@ public void ConsoleTestParse()
3839
var result = consoleParser.Parse();
3940
result.Success.Should().BeTrue("Match should be with success to " + fixture.device.model);
4041

41-
result.Match.Name.Should().BeEquivalentTo(fixture.device.model, "Names should be equal");
42-
DeviceDetectorNET.Parser.Device.Devices.GetFullName(result.Match.Brand).Should()
43-
.BeEquivalentTo(fixture.device.brand, "Brand should be equal");
4442
result.Match.Type.Should().Be(DeviceDetectorNET.Parser.Device.Devices.DeviceTypes[fixture.device.type],
4543
"Types should be equal");
46-
}
47-
}
4844

49-
[Fact]
50-
public void Test()
51-
{
52-
var ua = @"Mozilla/5.0 (Linux; Android 4.2.2; ARCHOS 101 PLATINUM Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Safari/537.36";
53-
var consoleParser = new ConsoleParser();
54-
consoleParser.SetUserAgent(ua);
55-
consoleParser.Parse();
45+
result.Match.Brand.Should().BeEquivalentTo(fixture.device.brand, "Brand should be equal");
46+
result.Match.Model.Should().BeEquivalentTo(fixture.device.model, "Model should be equal");
47+
48+
}
5649
}
5750
}
5851
}

DeviceDetector.NET.Tests/Parser/Devices/DevicesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void DeviceBrandsTest()
2323
.DeviceBrands
2424
.Count
2525
.Should()
26-
.Be(1592);
26+
.Be(1595);
2727
}
2828
}
2929
}

DeviceDetector.NET.Tests/Parser/Devices/NotebookTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ public void NotebookTestParse()
2929
var result = notebookParser.Parse();
3030
result.Success.Should().BeTrue("Match should be with success to " + fixture.device.model);
3131

32-
result.Match.Name.Should().BeEquivalentTo(fixture.device.model, "Names should be equal");
33-
DeviceDetectorNET.Parser.Device.Devices.GetFullName(result.Match.Brand).Should()
34-
.BeEquivalentTo(fixture.device.brand, "Brand should be equal");
3532
result.Match.Type.Should().Be(DeviceDetectorNET.Parser.Device.Devices.DeviceTypes[fixture.device.type],
3633
"Types should be equal");
34+
result.Match.Brand.Should().BeEquivalentTo(fixture.device.brand, "Brand should be equal");
35+
result.Match.Model.Should().BeEquivalentTo(fixture.device.model, "Model should be equal");
36+
3737
}
3838
}
3939
}

DeviceDetector.NET.Tests/fixtures/bots.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5530,3 +5530,30 @@
55305530
producer:
55315531
name: IAB Technology Laboratory, Inc.
55325532
url: https://iabtechlab.com/
5533+
-
5534+
user_agent: 'Mozilla/5.0 (compatible;Cloudflare-Healthchecks/1.0;+https://www.cloudflare.com/; healthcheck-id: e645d1e65d3b18b4)'
5535+
bot:
5536+
name: Cloudflare Health Checks
5537+
category: Service Agent
5538+
url: https://developers.cloudflare.com/health-checks/
5539+
producer:
5540+
name: CloudFlare
5541+
url: http://www.cloudflare.com
5542+
-
5543+
user_agent: Mozilla/5.0 (Morningscore/1.0)
5544+
bot:
5545+
name: Morning Score
5546+
category: Crawler
5547+
url: https://morningscore.io/
5548+
producer:
5549+
name: Morningscore
5550+
url: https://morningscore.io/
5551+
-
5552+
user_agent: Mozilla/5.0 (Morningscore Bot/1.0)
5553+
bot:
5554+
name: Morning Score
5555+
category: Crawler
5556+
url: https://morningscore.io/
5557+
producer:
5558+
name: Morningscore
5559+
url: https://morningscore.io/

DeviceDetector.NET.Tests/fixtures/mobile_apps.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,3 +1885,83 @@
18851885
model: ""
18861886
os_family: Windows
18871887
browser_family: Unknown
1888+
-
1889+
user_agent: bonprix mobile App 1.48 (20210412.1) (iOS 14.5; iPhone12,5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1
1890+
os:
1891+
name: iOS
1892+
version: "14.5"
1893+
platform: ""
1894+
client:
1895+
type: mobile app
1896+
name: BonPrix
1897+
version: "1.48"
1898+
device:
1899+
type: phablet
1900+
brand: Apple
1901+
model: iPhone 11 Pro Max
1902+
os_family: iOS
1903+
browser_family: Unknown
1904+
-
1905+
user_agent: bonprix mobile App 1.30 (2019040100); Android 8.1.0 API 27; HUAWEI DRA-L01; Mozilla/5.0 (Linux; Android 8.1.0; DRA-L01 Build/HUAWEIDRA-L01; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.73 Mobile Safari/537.36
1906+
os:
1907+
name: Android
1908+
version: 8.1.0
1909+
platform: ""
1910+
client:
1911+
type: mobile app
1912+
name: BonPrix
1913+
version: "1.30"
1914+
device:
1915+
type: smartphone
1916+
brand: Huawei
1917+
model: Y5 (2018)
1918+
os_family: Android
1919+
browser_family: Unknown
1920+
-
1921+
user_agent: TurboDL/1.0 (iPhone; iOS 10.3.3; Scale/2.00)
1922+
os:
1923+
name: iOS
1924+
version: 10.3.3
1925+
platform: ""
1926+
client:
1927+
type: mobile app
1928+
name: TurboDL
1929+
version: "1.0"
1930+
device:
1931+
type: smartphone
1932+
brand: Apple
1933+
model: iPhone
1934+
os_family: iOS
1935+
browser_family: Unknown
1936+
-
1937+
user_agent: Mozilla/5.0 (iPhone12,3; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit (KHTML, like Gecko) Version/14.0 Mobile Safari Quora 8.0.0 rv:2194
1938+
os:
1939+
name: iOS
1940+
version: "14.0"
1941+
platform: ""
1942+
client:
1943+
type: mobile app
1944+
name: Quora
1945+
version: 8.0.0
1946+
device:
1947+
type: phablet
1948+
brand: Apple
1949+
model: iPhone 11 Pro
1950+
os_family: iOS
1951+
browser_family: Unknown
1952+
-
1953+
user_agent: relesys_web_client/1.2.9.0 (iOS/12.4.1; Apple; iPhone) RelesysApp/1.3.17 (24) net.relesysapp.jj2go
1954+
os:
1955+
name: iOS
1956+
version: 12.4.1
1957+
platform: ""
1958+
client:
1959+
type: mobile app
1960+
name: JJ2GO
1961+
version: 1.3.17
1962+
device:
1963+
type: smartphone
1964+
brand: Apple
1965+
model: iPhone
1966+
os_family: iOS
1967+
browser_family: Unknown

DeviceDetector.NET.Tests/fixtures/portable_media_player.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,3 +773,21 @@
773773
model: Touch
774774
os_family: Android
775775
browser_family: Chrome
776+
-
777+
user_agent: Mozilla/5.0 (Linux; Android 12; NW-A300Series) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Mobile Safari/537.36
778+
os:
779+
name: Android
780+
version: "12"
781+
platform: ""
782+
client:
783+
type: browser
784+
name: Chrome Mobile
785+
version: 105.0.0.0
786+
engine: Blink
787+
engine_version: 105.0.0.0
788+
device:
789+
type: portable media player
790+
brand: Sony
791+
model: Walkman A300
792+
os_family: Android
793+
browser_family: Chrome

0 commit comments

Comments
 (0)