diff --git a/.editorconfig b/.editorconfig
index cbf76fc..f626676 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -72,9 +72,9 @@ dotnet_code_quality_unused_parameters = all:suggestion
#### C# Coding Conventions ####
# var preferences
-csharp_style_var_elsewhere = false:silent
-csharp_style_var_for_built_in_types = false:silent
-csharp_style_var_when_type_is_apparent = true:silent
+dotnet_style_var_for_built_in_types = false:error
+dotnet_style_var_when_type_is_apparent = false:error
+dotnet_style_var_elsewhere = false:error
# Expression-bodied members
csharp_style_expression_bodied_accessors = true:silent
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5c8c185..73f2b79 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -18,7 +18,6 @@
-
@@ -48,4 +47,4 @@
runtime; build; native; contentfiles; analyzers
-
\ No newline at end of file
+
diff --git a/src/MyCSharp.HttpUserAgentParser.MemoryCache/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensions.cs b/src/MyCSharp.HttpUserAgentParser.MemoryCache/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensions.cs
index 57045cf..ba4e4d6 100644
--- a/src/MyCSharp.HttpUserAgentParser.MemoryCache/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensions.cs
+++ b/src/MyCSharp.HttpUserAgentParser.MemoryCache/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensions.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using System;
using Microsoft.Extensions.DependencyInjection;
using MyCSharp.HttpUserAgentParser.DependencyInjection;
using MyCSharp.HttpUserAgentParser.Providers;
diff --git a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
index 15c05b8..85bea8b 100644
--- a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using MyCSharp.HttpUserAgentParser.AspNetCore.DependencyInjection;
using MyCSharp.HttpUserAgentParser.DependencyInjection;
@@ -18,10 +17,10 @@ public void AddHttpUserAgentParserAccessor()
options.AddHttpUserAgentParserAccessor();
- services.Count.Should().Be(1);
+ Assert.Single(services);
- services[0].ServiceType.Should().Be();
- services[0].ImplementationType.Should().Be();
- services[0].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.Equal(typeof(IHttpUserAgentParserAccessor), services[0].ServiceType);
+ Assert.Equal(typeof(HttpUserAgentParserAccessor), services[0].ImplementationType);
+ Assert.Equal(ServiceLifetime.Singleton, services[0].Lifetime);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/HttpUserAgentParserAccessorTests.cs b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/HttpUserAgentParserAccessorTests.cs
index ba7dd00..29b3c1d 100644
--- a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/HttpUserAgentParserAccessorTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/HttpUserAgentParserAccessorTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.AspNetCore.Http;
using MyCSharp.HttpUserAgentParser.Providers;
using NSubstitute;
@@ -27,8 +26,8 @@ public void Get(string userAgent)
HttpUserAgentInformation? info = accessor.Get(httpContext);
// assert
- info.Should().NotBeNull();
- info.Should().Be(userAgentInformation);
+ Assert.NotNull(info);
+ Assert.Equal(userAgentInformation, info);
// verify
_parserMock.Received(1).Parse(userAgent);
diff --git a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests.csproj b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests.csproj
index 3e6bd37..3d4c3ed 100644
--- a/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests.csproj
+++ b/tests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests/MyCSharp.HttpUserAgentParser.AspNetCore.UnitTests.csproj
@@ -4,6 +4,10 @@
Exe
+
+
+
+
all
@@ -20,9 +24,6 @@
-
-
-
diff --git a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensionssTests.cs b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensionssTests.cs
index 215ae1c..e53e1a5 100644
--- a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensionssTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/DependencyInjection/HttpUserAgentParserMemoryCacheServiceCollectionExtensionssTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using MyCSharp.HttpUserAgentParser.MemoryCache.DependencyInjection;
using MyCSharp.HttpUserAgentParser.Providers;
@@ -17,13 +16,13 @@ public void AddHttpUserAgentMemoryCachedParser()
services.AddHttpUserAgentMemoryCachedParser();
- services.Count.Should().Be(2);
+ Assert.Equal(2, services.Count);
- services[0].ImplementationInstance.Should().BeOfType();
- services[0].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.IsType(services[0].ImplementationInstance);
+ Assert.Equal(ServiceLifetime.Singleton, services[0].Lifetime);
- services[1].ServiceType.Should().Be();
- services[1].ImplementationType.Should().Be();
- services[1].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.Equal(typeof(IHttpUserAgentParserProvider), services[1].ServiceType);
+ Assert.Equal(typeof(HttpUserAgentParserMemoryCachedProvider), services[1].ImplementationType);
+ Assert.Equal(ServiceLifetime.Singleton, services[1].Lifetime);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderOptionsTests.cs b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderOptionsTests.cs
index 9397352..44f093b 100644
--- a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderOptionsTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderOptionsTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.Extensions.Caching.Memory;
using Xunit;
@@ -16,8 +15,8 @@ public void Ctor()
HttpUserAgentParserMemoryCachedProviderOptions options = new(cacheOptions, cacheEntryOptions);
- options.CacheOptions.Should().Be(cacheOptions);
- options.CacheEntryOptions.Should().Be(cacheEntryOptions);
+ Assert.Equal(cacheOptions, options.CacheOptions);
+ Assert.Equal(cacheEntryOptions, options.CacheEntryOptions);
}
[Fact]
@@ -27,8 +26,8 @@ public void Ctor_MemoryCacheOptions()
HttpUserAgentParserMemoryCachedProviderOptions options = new(cacheOptions);
- options.CacheOptions.Should().Be(cacheOptions);
- options.CacheEntryOptions.Should().NotBeNull();
+ Assert.Equal(cacheOptions, options.CacheOptions);
+ Assert.NotNull(options.CacheEntryOptions);
}
[Fact]
@@ -38,8 +37,8 @@ public void Ctor_MemoryCacheEntryOptions()
HttpUserAgentParserMemoryCachedProviderOptions options = new(cacheEntryOptions);
- options.CacheOptions.Should().NotBeNull();
- options.CacheEntryOptions.Should().Be(cacheEntryOptions);
+ Assert.NotNull(options.CacheOptions);
+ Assert.Equal(cacheEntryOptions, options.CacheEntryOptions);
}
[Fact]
@@ -47,7 +46,7 @@ public void Ctor_Empty()
{
HttpUserAgentParserMemoryCachedProviderOptions options = new();
- options.CacheOptions.Should().NotBeNull();
- options.CacheEntryOptions.Should().NotBeNull();
+ Assert.NotNull(options.CacheOptions);
+ Assert.NotNull(options.CacheEntryOptions);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderTests.cs b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderTests.cs
index ce7e481..efcabe2 100644
--- a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/HttpUserAgentParserMemoryCachedProviderTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests;
@@ -14,28 +13,28 @@ public void Parse()
HttpUserAgentParserMemoryCachedProvider provider = new(cachedProviderOptions);
// create first
- string userAgentOne =
+ const string userAgentOne =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62";
HttpUserAgentInformation infoOne = provider.Parse(userAgentOne);
- infoOne.Name.Should().Be("Edge");
- infoOne.Version.Should().Be("90.0.818.62");
+ Assert.Equal("Edge", infoOne.Name);
+ Assert.Equal("90.0.818.62", infoOne.Version);
// check duplicate
HttpUserAgentInformation infoDuplicate = provider.Parse(userAgentOne);
- infoDuplicate.Name.Should().Be("Edge");
- infoDuplicate.Version.Should().Be("90.0.818.62");
+ Assert.Equal("Edge", infoDuplicate.Name);
+ Assert.Equal("90.0.818.62", infoDuplicate.Version);
// create second
- string userAgentTwo = "Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0";
+ const string userAgentTwo = "Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0";
HttpUserAgentInformation infoTwo = provider.Parse(userAgentTwo);
- infoTwo.Name.Should().Be("Firefox");
- infoTwo.Version.Should().Be("41.0");
+ Assert.Equal("Firefox", infoTwo.Name);
+ Assert.Equal("41.0", infoTwo.Version);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests.csproj b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests.csproj
index 1e6b572..05efe7c 100644
--- a/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests.csproj
+++ b/tests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests/MyCSharp.HttpUserAgentParser.MemoryCache.UnitTests.csproj
@@ -4,6 +4,11 @@
Exe
+
+
+
+
+
all
@@ -20,12 +25,8 @@
-
-
-
-
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserDependencyInjectionOptions.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserDependencyInjectionOptions.cs
index ae03ea3..6981a98 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserDependencyInjectionOptions.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserDependencyInjectionOptions.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using MyCSharp.HttpUserAgentParser.DependencyInjection;
using NSubstitute;
@@ -17,6 +16,6 @@ public void Ctor_Should_Set_Property()
{
HttpUserAgentParserDependencyInjectionOptions options = new(_scMock);
- options.Services.Should().BeEquivalentTo(_scMock);
+ Assert.Equal(_scMock, options.Services);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
index c5ec4e5..c7c97dd 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/DependencyInjection/HttpUserAgentParserServiceCollectionExtensionsTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using MyCSharp.HttpUserAgentParser.DependencyInjection;
using MyCSharp.HttpUserAgentParser.Providers;
@@ -22,10 +21,10 @@ public void AddHttpUserAgentParser()
services.AddHttpUserAgentParser();
- services.Count.Should().Be(1);
- services[0].ServiceType.Should().Be();
- services[0].ImplementationType.Should().Be();
- services[0].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.Single(services);
+ Assert.Equal(typeof(IHttpUserAgentParserProvider), services[0].ServiceType);
+ Assert.Equal(typeof(HttpUserAgentParserDefaultProvider), services[0].ImplementationType);
+ Assert.Equal(ServiceLifetime.Singleton, services[0].Lifetime);
}
[Fact]
@@ -35,10 +34,10 @@ public void AddHttpUserAgentCachedParser()
services.AddHttpUserAgentCachedParser();
- services.Count.Should().Be(1);
- services[0].ServiceType.Should().Be();
- services[0].ImplementationType.Should().Be();
- services[0].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.Single(services);
+ Assert.Equal(typeof(IHttpUserAgentParserProvider), services[0].ServiceType);
+ Assert.Equal(typeof(HttpUserAgentParserCachedProvider), services[0].ImplementationType);
+ Assert.Equal(ServiceLifetime.Singleton, services[0].Lifetime);
}
[Fact]
@@ -48,9 +47,9 @@ public void AddHttpUserAgentParser_With_Generic()
services.AddHttpUserAgentParser();
- services.Count.Should().Be(1);
- services[0].ServiceType.Should().Be();
- services[0].ImplementationType.Should().Be();
- services[0].Lifetime.Should().Be(ServiceLifetime.Singleton);
+ Assert.Single(services);
+ Assert.Equal(typeof(IHttpUserAgentParserProvider), services[0].ServiceType);
+ Assert.Equal(typeof(TestHttpUserAgentParserProvider), services[0].ImplementationType);
+ Assert.Equal(ServiceLifetime.Singleton, services[0].Lifetime);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationExtensionsTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationExtensionsTests.cs
index e626672..02301ef 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationExtensionsTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationExtensionsTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -22,32 +21,32 @@ public void IsType(string userAgent, HttpUserAgentType expectedType, bool isMobi
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);
+ Assert.True(info.IsType(HttpUserAgentType.Browser));
+ Assert.False(info.IsType(HttpUserAgentType.Robot));
+ Assert.False(info.IsType(HttpUserAgentType.Unknown));
- info.IsBrowser().Should().Be(true);
- info.IsRobot().Should().Be(false);
+ Assert.True(info.IsBrowser());
+ Assert.False(info.IsRobot());
}
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);
+ Assert.False(info.IsType(HttpUserAgentType.Browser));
+ Assert.True(info.IsType(HttpUserAgentType.Robot));
+ Assert.False(info.IsType(HttpUserAgentType.Unknown));
- info.IsBrowser().Should().Be(false);
- info.IsRobot().Should().Be(true);
+ Assert.False(info.IsBrowser());
+ Assert.True(info.IsRobot());
}
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);
+ Assert.False(info.IsType(HttpUserAgentType.Browser));
+ Assert.False(info.IsType(HttpUserAgentType.Robot));
+ Assert.True(info.IsType(HttpUserAgentType.Unknown));
- info.IsBrowser().Should().Be(false);
- info.IsRobot().Should().Be(false);
+ Assert.False(info.IsBrowser());
+ Assert.False(info.IsRobot());
}
- info.IsMobile().Should().Be(isMobile);
+ Assert.Equal(isMobile, info.IsMobile());
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationTests.cs
index 675294a..4022d27 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentInformationTests.cs
@@ -1,7 +1,6 @@
// Copyright © myCSharp.de - all rights reserved
using System.Text.RegularExpressions;
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -15,7 +14,7 @@ public void Parse(string userAgent)
HttpUserAgentInformation ua1 = HttpUserAgentParser.Parse(userAgent);
HttpUserAgentInformation ua2 = HttpUserAgentInformation.Parse(userAgent);
- ua1.Should().BeEquivalentTo(ua2);
+ Assert.Equal(ua2, ua1);
}
[Theory]
@@ -24,12 +23,12 @@ public void CreateForRobot(string userAgent)
{
HttpUserAgentInformation ua = HttpUserAgentInformation.CreateForRobot(userAgent, "Chrome");
- ua.UserAgent.Should().Be(userAgent);
- ua.Type.Should().Be(HttpUserAgentType.Robot);
- ua.Platform.Should().Be(null);
- ua.Name.Should().Be("Chrome");
- ua.Version.Should().Be(null);
- ua.MobileDeviceType.Should().Be(null);
+ Assert.Equal(userAgent, ua.UserAgent);
+ Assert.Equal(HttpUserAgentType.Robot, ua.Type);
+ Assert.Null(ua.Platform);
+ Assert.Equal("Chrome", ua.Name);
+ Assert.Null(ua.Version);
+ Assert.Null(ua.MobileDeviceType);
}
[Theory]
@@ -37,17 +36,17 @@ public void CreateForRobot(string userAgent)
public void CreateForBrowser(string userAgent)
{
HttpUserAgentPlatformInformation platformInformation =
- new HttpUserAgentPlatformInformation(new Regex(""), "Android", HttpUserAgentPlatformType.Android);
+ new(new Regex(""), "Android", HttpUserAgentPlatformType.Android);
HttpUserAgentInformation ua = HttpUserAgentInformation.CreateForBrowser(userAgent,
platformInformation, "Edge", "46.3.4.5155", "Android");
- ua.UserAgent.Should().Be(userAgent);
- ua.Type.Should().Be(HttpUserAgentType.Browser);
- ua.Platform.Should().Be(platformInformation);
- ua.Name.Should().Be("Edge");
- ua.Version.Should().Be("46.3.4.5155");
- ua.MobileDeviceType.Should().Be("Android");
+ Assert.Equal(userAgent, ua.UserAgent);
+ Assert.Equal(HttpUserAgentType.Browser, ua.Type);
+ Assert.Equal(platformInformation, ua.Platform);
+ Assert.Equal("Edge", ua.Name);
+ Assert.Equal("46.3.4.5155", ua.Version);
+ Assert.Equal("Android", ua.MobileDeviceType);
}
[Theory]
@@ -60,11 +59,11 @@ public void CreateForUnknown(string userAgent)
HttpUserAgentInformation ua =
HttpUserAgentInformation.CreateForUnknown(userAgent, platformInformation, null);
- ua.UserAgent.Should().Be(userAgent);
- ua.Type.Should().Be(HttpUserAgentType.Unknown);
- ua.Platform.Should().Be(platformInformation);
- ua.Name.Should().Be(null);
- ua.Version.Should().Be(null);
- ua.MobileDeviceType.Should().Be(null);
+ Assert.Equal(userAgent, ua.UserAgent);
+ Assert.Equal(HttpUserAgentType.Unknown, ua.Type);
+ Assert.Equal(platformInformation, ua.Platform);
+ Assert.Null(ua.Name);
+ Assert.Null(ua.Version);
+ Assert.Null(ua.MobileDeviceType);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentParserTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentParserTests.cs
index 2e245be..e8d73c0 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentParserTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentParserTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -58,21 +57,21 @@ public void BrowserTests(string ua, string name, string version, string platform
{
HttpUserAgentInformation uaInfo = HttpUserAgentInformation.Parse(ua);
- uaInfo.Name.Should().Be(name);
- uaInfo.Version.Should().Be(version);
- uaInfo.UserAgent.Should().Be(ua);
+ Assert.Equal(name, uaInfo.Name);
+ Assert.Equal(version, uaInfo.Version);
+ Assert.Equal(ua, uaInfo.UserAgent);
- uaInfo.Type.Should().Be(HttpUserAgentType.Browser);
+ Assert.Equal(HttpUserAgentType.Browser, uaInfo.Type);
HttpUserAgentPlatformInformation platform = uaInfo.Platform.GetValueOrDefault();
- platform.PlatformType.Should().Be(platformType);
- platform.Name.Should().Be(platformName);
+ Assert.Equal(platformType, platform.PlatformType);
+ Assert.Equal(platformName, platform.Name);
- uaInfo.MobileDeviceType.Should().Be(mobileDeviceType);
+ Assert.Equal(mobileDeviceType, uaInfo.MobileDeviceType);
- uaInfo.IsBrowser().Should().Be(true);
- uaInfo.IsMobile().Should().Be(mobileDeviceType is not null);
- uaInfo.IsRobot().Should().Be(false);
+ Assert.True(uaInfo.IsBrowser());
+ Assert.Equal(mobileDeviceType is not null, uaInfo.IsMobile());
+ Assert.False(uaInfo.IsRobot());
}
[Theory]
@@ -137,17 +136,17 @@ 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);
+ Assert.Equal(name, uaInfo.Name);
+ Assert.Null(uaInfo.Version);
+ Assert.Equal(ua, uaInfo.UserAgent);
- uaInfo.Type.Should().Be(HttpUserAgentType.Robot);
+ Assert.Equal(HttpUserAgentType.Robot, uaInfo.Type);
- uaInfo.Platform.Should().Be(null);
- uaInfo.MobileDeviceType.Should().Be(null);
+ Assert.Null(uaInfo.Platform);
+ Assert.Null(uaInfo.MobileDeviceType);
- uaInfo.IsBrowser().Should().Be(false);
- uaInfo.IsMobile().Should().Be(false);
- uaInfo.IsRobot().Should().Be(true);
+ Assert.False(uaInfo.IsBrowser());
+ Assert.False(uaInfo.IsMobile());
+ Assert.True(uaInfo.IsRobot());
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformInformationTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformInformationTests.cs
index c394d6f..cb69ca2 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformInformationTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformInformationTests.cs
@@ -1,7 +1,6 @@
// Copyright © myCSharp.de - all rights reserved
using System.Text.RegularExpressions;
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -17,8 +16,8 @@ public void Ctor(string name, HttpUserAgentPlatformType platform)
HttpUserAgentPlatformInformation info = new(regex, name, platform);
- info.Regex.Should().Be(regex);
- info.Name.Should().Be(name);
- info.PlatformType.Should().Be(platform);
+ Assert.Equal(regex, info.Regex);
+ Assert.Equal(name, info.Name);
+ Assert.Equal(platform, info.PlatformType);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformTypeTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformTypeTests.cs
index 5a0b9eb..7efc396 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformTypeTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentPlatformTypeTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -20,6 +19,6 @@ public class HttpUserAgentPlatformTypeTests
[InlineData(HttpUserAgentPlatformType.Symbian, 9)]
public void TestValue(HttpUserAgentPlatformType type, byte value)
{
- ((byte)type == value).Should().Be(true);
+ Assert.True((byte)type == value);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentTypeTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentTypeTests.cs
index 1953f9d..c1c5cb7 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentTypeTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/HttpUserAgentTypeTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using Xunit;
namespace MyCSharp.HttpUserAgentParser.UnitTests;
@@ -13,6 +12,6 @@ public class HttpUserAgentTypeTests
[InlineData(HttpUserAgentType.Robot, 2)]
public void TestValue(HttpUserAgentType type, byte value)
{
- ((byte)type == value).Should().Be(true);
+ Assert.True((byte)type == value);
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/MyCSharp.HttpUserAgentParser.UnitTests.csproj b/tests/MyCSharp.HttpUserAgentParser.UnitTests/MyCSharp.HttpUserAgentParser.UnitTests.csproj
index 4d2dcbb..24f53dd 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/MyCSharp.HttpUserAgentParser.UnitTests.csproj
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/MyCSharp.HttpUserAgentParser.UnitTests.csproj
@@ -4,10 +4,11 @@
Exe
-
+
+
-
+
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserCachedProviderTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserCachedProviderTests.cs
index 6ee544b..db04bff 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserCachedProviderTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserCachedProviderTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using MyCSharp.HttpUserAgentParser.Providers;
using Xunit;
@@ -11,42 +10,42 @@ public class HttpUserAgentParserCachedProviderTests
[Fact]
public void Parse()
{
- HttpUserAgentParserCachedProvider provider = new HttpUserAgentParserCachedProvider();
+ HttpUserAgentParserCachedProvider provider = new();
- provider.CacheEntryCount.Should().Be(0);
+ Assert.Equal(0, provider.CacheEntryCount);
// create first
- string userAgentOne =
+ const string userAgentOne =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 Edg/90.0.818.62";
HttpUserAgentInformation infoOne = provider.Parse(userAgentOne);
- infoOne.Name.Should().Be("Edge");
- infoOne.Version.Should().Be("90.0.818.62");
+ Assert.Equal("Edge", infoOne.Name);
+ Assert.Equal("90.0.818.62", infoOne.Version);
- provider.CacheEntryCount.Should().Be(1);
- provider.HasCacheEntry(userAgentOne).Should().Be(true);
+ Assert.Equal(1, provider.CacheEntryCount);
+ Assert.True(provider.HasCacheEntry(userAgentOne));
// check duplicate
HttpUserAgentInformation infoDuplicate = provider.Parse(userAgentOne);
- infoDuplicate.Name.Should().Be("Edge");
- infoDuplicate.Version.Should().Be("90.0.818.62");
+ Assert.Equal("Edge", infoDuplicate.Name);
+ Assert.Equal("90.0.818.62", infoDuplicate.Version);
- provider.CacheEntryCount.Should().Be(1);
- provider.HasCacheEntry(userAgentOne).Should().Be(true);
+ Assert.Equal(1, provider.CacheEntryCount);
+ Assert.True(provider.HasCacheEntry(userAgentOne));
// create second
- string userAgentTwo = "Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0";
+ const string userAgentTwo = "Mozilla/5.0 (Android 4.4; Tablet; rv:41.0) Gecko/41.0 Firefox/41.0";
HttpUserAgentInformation infoTwo = provider.Parse(userAgentTwo);
- infoTwo.Name.Should().Be("Firefox");
- infoTwo.Version.Should().Be("41.0");
+ Assert.Equal("Firefox", infoTwo.Name);
+ Assert.Equal("41.0", infoTwo.Version);
- provider.CacheEntryCount.Should().Be(2);
- provider.HasCacheEntry(userAgentTwo).Should().Be(true);
+ Assert.Equal(2, provider.CacheEntryCount);
+ Assert.True(provider.HasCacheEntry(userAgentTwo));
}
}
diff --git a/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserDefaultProviderTests.cs b/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserDefaultProviderTests.cs
index 134e6cb..4b9f740 100644
--- a/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserDefaultProviderTests.cs
+++ b/tests/MyCSharp.HttpUserAgentParser.UnitTests/Providers/HttpUserAgentParserDefaultProviderTests.cs
@@ -1,6 +1,5 @@
// Copyright © myCSharp.de - all rights reserved
-using FluentAssertions;
using MyCSharp.HttpUserAgentParser.Providers;
using Xunit;
@@ -17,6 +16,6 @@ public void Parse(string userAgent)
HttpUserAgentInformation providerUserAgentInfo = provider.Parse(userAgent);
HttpUserAgentInformation userAgentInfo = HttpUserAgentInformation.Parse(userAgent);
- providerUserAgentInfo.Should().BeEquivalentTo(userAgentInfo);
+ Assert.Equal(userAgentInfo, providerUserAgentInfo);
}
}