Skip to content

Commit

Permalink
refactor: replace .NET Core 3.1 with .NET 7 to test .NET Standard 2.1. (
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer authored Oct 6, 2024
1 parent cbd8190 commit d218ae0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<NoWarn>$(NoWarn);NU1902;NU1903;xUnit1042</NoWarn>
<NetTestSdkVersion>17.11.1</NetTestSdkVersion>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>

<TestNetStandard21 Condition="'$(TargetFramework)'=='net7.0'">true</TestNetStandard21>
<DefineConstants Condition="'$(TestNetStandard21)'=='true'">$(DefineConstants);TEST_NETSTANDARD2_1</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
Expand Down
7 changes: 5 additions & 2 deletions test/MockHttp.Json.Tests/MockHttp.Json.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462</TargetFrameworks>

<IsTestProject>true</IsTestProject>

Expand All @@ -14,7 +14,10 @@

<ItemGroup>
<ProjectReference Include="..\MockHttp.Testing\MockHttp.Testing.csproj" />
<ProjectReference Include="..\..\src\MockHttp.Json\MockHttp.Json.csproj" />
<!-- For coverage purposes, override default dependency resolution and instead target specific frameworks. -->
<ProjectReference Include="..\..\src\MockHttp.Json\MockHttp.Json.csproj" Condition="'$(TestNetStandard21)'==''" />
<ProjectReference Include="..\..\src\MockHttp.Json\MockHttp.Json.csproj" Condition="'$(TestNetStandard21)'=='true'" AdditionalProperties="TargetFramework=netstandard2.1" />

</ItemGroup>

</Project>
8 changes: 5 additions & 3 deletions test/MockHttp.Testing/MockHttp.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462</TargetFrameworks>

<IsTestProject>false</IsTestProject>

<RootNamespace>MockHttp</RootNamespace>

<VerifyVersion>26.6.0</VerifyVersion>
<VerifyVersion Condition="'$(TargetFramework)'=='net5.0' Or '$(TargetFramework)'=='netcoreapp3.1' Or '$(TargetFramework)'=='net462'">20.8.2</VerifyVersion>
<VerifyVersion Condition="'$(TargetFramework)'=='net5.0' Or '$(TargetFramework)'=='net462'">20.8.2</VerifyVersion>
<VerifyVersion Condition="'$(TargetFramework)'=='netcoreapp2.1'">18.1.0</VerifyVersion>
<VerifyPublicApi Condition="'$(VerifyPublicApi)'==''">true</VerifyPublicApi>
<DefineConstants Condition="'$(VerifyPublicApi)'=='true'">$(DefineConstants);VERIFY_PUBLIC_API</DefineConstants>
Expand All @@ -25,7 +25,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\MockHttp\MockHttp.csproj" />
<!-- For coverage purposes, override default dependency resolution and instead target specific frameworks. -->
<ProjectReference Include="..\..\src\MockHttp\MockHttp.csproj" Condition="'$(TestNetStandard21)'==''" />
<ProjectReference Include="..\..\src\MockHttp\MockHttp.csproj" Condition="'$(TestNetStandard21)'=='true'" AdditionalProperties="TargetFramework=netstandard2.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/MockHttp.Testing/Specs/PublicApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
);
Expand Down
3 changes: 1 addition & 2 deletions test/MockHttp.Tests/Internal/Http/EmptyContentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,22 @@ 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.")]
[InlineData(" leading-whitespace-not-allowed:value", "The header name format is invalid.")]
[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)
{
Expand Down
5 changes: 4 additions & 1 deletion test/MockHttp.Tests/MockHttp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472;net462</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;net5.0;netcoreapp2.1;net48;net472;net462</TargetFrameworks>

<IsTestProject>true</IsTestProject>

Expand All @@ -14,6 +14,9 @@

<ItemGroup>
<ProjectReference Include="..\MockHttp.Testing\MockHttp.Testing.csproj" />
<!-- For coverage purposes, override default dependency resolution and instead target specific frameworks. -->
<ProjectReference Include="..\..\src\MockHttp\MockHttp.csproj" Condition="'$(TestNetStandard21)'==''" />
<ProjectReference Include="..\..\src\MockHttp\MockHttp.csproj" Condition="'$(TestNetStandard21)'=='true'" AdditionalProperties="TargetFramework=netstandard2.1" />
</ItemGroup>

</Project>

0 comments on commit d218ae0

Please sign in to comment.