From 2a1c761fe71ef7d1492117c8d3315b6eae0ab6fb Mon Sep 17 00:00:00 2001 From: skwasjer <11424653+skwasjer@users.noreply.github.com> Date: Sun, 6 Oct 2024 05:59:15 +0200 Subject: [PATCH] refactor: replace .NET Core 3.1 with .NET 7 to test .NET Standard 2.1. --- test/Directory.Build.targets | 3 +++ test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj | 7 +++++-- ...d.txt => .NET_Standard_2.1_via_.NET_7.0.verified.txt} | 0 test/MockHttp.Testing/MockHttp.Testing.csproj | 8 +++++--- test/MockHttp.Testing/Specs/PublicApiSpec.cs | 2 +- test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs | 3 +-- .../Internal/Http/HttpHeadersCollectionTests.cs | 9 +++++++++ test/MockHttp.Tests/MockHttp.Tests.csproj | 5 ++++- ...d.txt => .NET_Standard_2.1_via_.NET_7.0.verified.txt} | 0 9 files changed, 28 insertions(+), 9 deletions(-) rename test/MockHttp.Json.Tests/PublicApi/{.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt => .NET_Standard_2.1_via_.NET_7.0.verified.txt} (100%) rename test/MockHttp.Tests/PublicApi/{.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt => .NET_Standard_2.1_via_.NET_7.0.verified.txt} (100%) diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index e50c4afd..fb66ddc0 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -6,6 +6,9 @@ $(NoWarn);NU1902;NU1903;xUnit1042 17.11.1 true + + true + $(DefineConstants);TEST_NETSTANDARD2_1 diff --git a/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj b/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj index e61161eb..fb32704b 100644 --- a/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj +++ b/test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 true @@ -14,7 +14,10 @@ - + + + + \ No newline at end of file diff --git a/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt b/test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_7.0.verified.txt similarity index 100% rename from test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt rename to test/MockHttp.Json.Tests/PublicApi/.NET_Standard_2.1_via_.NET_7.0.verified.txt diff --git a/test/MockHttp.Testing/MockHttp.Testing.csproj b/test/MockHttp.Testing/MockHttp.Testing.csproj index 70d7a1ae..f3fb2b26 100644 --- a/test/MockHttp.Testing/MockHttp.Testing.csproj +++ b/test/MockHttp.Testing/MockHttp.Testing.csproj @@ -1,14 +1,14 @@  - net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 false MockHttp 26.6.0 - 20.8.2 + 20.8.2 18.1.0 true $(DefineConstants);VERIFY_PUBLIC_API @@ -25,7 +25,9 @@ - + + + \ No newline at end of file diff --git a/test/MockHttp.Testing/Specs/PublicApiSpec.cs b/test/MockHttp.Testing/Specs/PublicApiSpec.cs index f6d091c6..39a45c36 100644 --- a/test/MockHttp.Testing/Specs/PublicApiSpec.cs +++ b/test/MockHttp.Testing/Specs/PublicApiSpec.cs @@ -45,7 +45,7 @@ public Task Api_has_not_changed() string sutTargetFramework = GetTargetFramework(sut); string testTargetFramework = GetTargetFramework(GetType().Assembly); settings.UseFileName( - sutTargetFramework == testTargetFramework + sutTargetFramework == testTargetFramework || string.IsNullOrEmpty(testTargetFramework) ? sutTargetFramework : $"{sutTargetFramework}_via_{testTargetFramework}" ); diff --git a/test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs b/test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs index e15b991a..5e2ea242 100644 --- a/test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs +++ b/test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs @@ -28,8 +28,7 @@ public async Task When_reading_stream_async_it_should_return_empty() stream.Length.Should().Be(0); } -#if NET6_0_OR_GREATER - +#if NET6_0_OR_GREATER && !TEST_NETSTANDARD2_1 [Fact] public async Task When_reading_stream_sync_it_should_return_empty() { diff --git a/test/MockHttp.Tests/Internal/Http/HttpHeadersCollectionTests.cs b/test/MockHttp.Tests/Internal/Http/HttpHeadersCollectionTests.cs index 5803d254..775e6d74 100644 --- a/test/MockHttp.Tests/Internal/Http/HttpHeadersCollectionTests.cs +++ b/test/MockHttp.Tests/Internal/Http/HttpHeadersCollectionTests.cs @@ -55,6 +55,14 @@ public void Given_single_header_string_when_parsing_should_return_key_with_one_o [InlineData("\tleading-whitespace-not-allowed:value", "The header name '\tleading-whitespace-not-allowed' has an invalid format.")] [InlineData("trailing-whitespace-not-allowed :value", "The header name 'trailing-whitespace-not-allowed ' has an invalid format.")] [InlineData("trailing-whitespace-not-allowed\t:value", "The header name 'trailing-whitespace-not-allowed\t' has an invalid format.")] +#else +#if TEST_NETSTANDARD2_1 + [InlineData(":value", "The value cannot be null or empty.*")] + [InlineData(" :value", "The header name ' ' has an invalid format.")] + [InlineData(" leading-whitespace-not-allowed:value", "The header name ' leading-whitespace-not-allowed' has an invalid format.")] + [InlineData("\tleading-whitespace-not-allowed:value", "The header name '\tleading-whitespace-not-allowed' has an invalid format.")] + [InlineData("trailing-whitespace-not-allowed :value", "The header name 'trailing-whitespace-not-allowed ' has an invalid format.")] + [InlineData("trailing-whitespace-not-allowed\t:value", "The header name 'trailing-whitespace-not-allowed\t' has an invalid format.")] #else [InlineData(":value", "The value cannot be null or empty.*")] [InlineData(" :value", "The header name format is invalid.")] @@ -62,6 +70,7 @@ public void Given_single_header_string_when_parsing_should_return_key_with_one_o [InlineData("\tleading-whitespace-not-allowed:value", "The header name format is invalid.")] [InlineData("trailing-whitespace-not-allowed :value", "The header name format is invalid.")] [InlineData("trailing-whitespace-not-allowed\t:value", "The header name format is invalid.")] +#endif #endif public void Given_single_invalid_header_string_with_when_parsing_should_throw(string invalidHeaderString, string exceptionMessage) { diff --git a/test/MockHttp.Tests/MockHttp.Tests.csproj b/test/MockHttp.Tests/MockHttp.Tests.csproj index 12655723..b7c51a88 100644 --- a/test/MockHttp.Tests/MockHttp.Tests.csproj +++ b/test/MockHttp.Tests/MockHttp.Tests.csproj @@ -1,7 +1,7 @@  - net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462 + net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462 true @@ -14,6 +14,9 @@ + + + diff --git a/test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt b/test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_7.0.verified.txt similarity index 100% rename from test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_Core_3.1.verified.txt rename to test/MockHttp.Tests/PublicApi/.NET_Standard_2.1_via_.NET_7.0.verified.txt