Skip to content

Commit 0dbe741

Browse files
authored
refactor: consolidate test project settings in Directory.Build.props (#1213)
Similar to #1211 but for test projects.
1 parent 9a0630b commit 0dbe741

File tree

5 files changed

+54
-58
lines changed

5 files changed

+54
-58
lines changed

System.IO.Abstractions.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks",
4848
EndProject
4949
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestableIO.System.IO.Abstractions.Api.Tests", "tests\TestableIO.System.IO.Abstractions.Api.Tests\TestableIO.System.IO.Abstractions.Api.Tests.csproj", "{7DE6AD74-E2B3-498E-90C5-DDF3188F333A}"
5050
EndProject
51+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{5971F640-8BBA-4264-BCD6-60A97DD54B4A}"
52+
ProjectSection(SolutionItems) = preProject
53+
tests\Directory.Build.props = tests\Directory.Build.props
54+
EndProjectSection
55+
EndProject
5156
Global
5257
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5358
Debug|Any CPU = Debug|Any CPU
@@ -105,6 +110,7 @@ Global
105110
{B66A0B3F-6A00-482E-99E2-27D8DECB075E} = {BBF7AD8D-5522-48C0-A906-00CBB72308A0}
106111
{015B3812-E01D-479C-895D-BDDF16E798CA} = {10F39E91-97F2-4812-9D2F-79BE18EC6B08}
107112
{7DE6AD74-E2B3-498E-90C5-DDF3188F333A} = {BCEC61BD-4941-41EC-975A-ACEFC7AC1780}
113+
{5971F640-8BBA-4264-BCD6-60A97DD54B4A} = {BBF7AD8D-5522-48C0-A906-00CBB72308A0}
108114
EndGlobalSection
109115
GlobalSection(ExtensibilityGlobals) = postSolution
110116
SolutionGuid = {8885C59C-F6A0-4C2F-A3BC-B720E9BD161F}

tests/Directory.Build.props

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<Project>
2+
3+
<Import Project="$(MSBuildThisFileDirectory)/../Directory.Build.props"
4+
Condition="Exists('$(MSBuildThisFileDirectory)/../Directory.Build.props')"/>
5+
6+
<PropertyGroup>
7+
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
8+
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net472</TargetFrameworks>
9+
<IsPackable>false</IsPackable>
10+
<IsTestable>true</IsTestable>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="coverlet.collector">
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
<PrivateAssets>all</PrivateAssets>
17+
</PackageReference>
18+
<PackageReference Include="GitHubActionsTestLogger" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
20+
<PackageReference Include="Moq" />
21+
<PackageReference Include="NUnit" />
22+
<PackageReference Include="NUnit.Analyzers">
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
<PrivateAssets>all</PrivateAssets>
25+
</PackageReference>
26+
<PackageReference Include="NUnit3TestAdapter" />
27+
</ItemGroup>
28+
29+
<PropertyGroup>
30+
<!--
31+
Allow deprecated binary formatter functionality on .NET 8 so that we can test it
32+
-->
33+
<EnableUnsafeBinaryFormatterSerialization Condition="'$(TargetFramework)' == 'net8.0'">true</EnableUnsafeBinaryFormatterSerialization>
34+
</PropertyGroup>
35+
36+
</Project>

tests/TestableIO.System.IO.Abstractions.Api.Tests/TestableIO.System.IO.Abstractions.Api.Tests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="GitHubActionsTestLogger" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
15-
<PackageReference Include="NUnit"/>
16-
<PackageReference Include="NUnit.Analyzers"/>
17-
<PackageReference Include="NUnit3TestAdapter"/>
1813
<PackageReference Include="PublicApiGenerator"/>
1914
<PackageReference Include="aweXpect"/>
2015
</ItemGroup>
Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
4-
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net472</TargetFrameworks>
54
<Description>The unit tests for our pre-built mocks</Description>
65
<AssemblyName>System.IO.Abstractions.TestingHelpers.Tests</AssemblyName>
76
<RootNamespace>System.IO.Abstractions.TestingHelpers.Tests</RootNamespace>
8-
<IsPackable>false</IsPackable>
9-
<IsTestable>true</IsTestable>
107
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="../../src/TestableIO.System.IO.Abstractions.TestingHelpers/TestableIO.System.IO.Abstractions.TestingHelpers.csproj" />
11+
</ItemGroup>
12+
1113
<PropertyGroup>
1214
<!--
1315
Ensure that test logger is copied to output directory, see
1416
https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5
1517
-->
1618
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1719
</PropertyGroup>
20+
1821
<ItemGroup>
1922
<None Remove="TestFiles\SecondTestFile.txt" />
2023
<None Remove="TestFiles\TestFile.txt" />
21-
</ItemGroup>
22-
<ItemGroup>
2324
<EmbeddedResource Include="TestFiles\SecondTestFile.txt" />
2425
<EmbeddedResource Include="TestFiles\TestFile.txt" />
2526
</ItemGroup>
26-
<ItemGroup>
27-
<ProjectReference Include="../../src/TestableIO.System.IO.Abstractions.TestingHelpers/TestableIO.System.IO.Abstractions.TestingHelpers.csproj" />
28-
</ItemGroup>
29-
<ItemGroup>
30-
<PackageReference Include="coverlet.collector">
31-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32-
<PrivateAssets>all</PrivateAssets>
33-
</PackageReference>
34-
<PackageReference Include="GitHubActionsTestLogger" />
35-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
36-
<PackageReference Include="Moq" />
37-
<PackageReference Include="NUnit" />
38-
<PackageReference Include="NUnit.Analyzers">
39-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
40-
<PrivateAssets>all</PrivateAssets>
41-
</PackageReference>
42-
<PackageReference Include="NUnit3TestAdapter" />
43-
</ItemGroup>
44-
<ItemGroup>
45-
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
46-
</ItemGroup>
47-
<PropertyGroup>
48-
<!--
49-
Allow deprecated binary formatter functionality on .NET 8 so that we can test it
50-
-->
51-
<EnableUnsafeBinaryFormatterSerialization Condition="'$(TargetFramework)' == 'net8.0'">true</EnableUnsafeBinaryFormatterSerialization>
52-
</PropertyGroup>
27+
5328
</Project>
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFrameworks>net9.0;net8.0;net6.0</TargetFrameworks>
4-
<TargetFrameworks Condition="!$([MSBuild]::IsOsUnixLike())">$(TargetFrameworks);net472</TargetFrameworks>
54
<Description>The unit tests for our the core abstractions</Description>
65
<AssemblyName>System.IO.Abstractions.Tests</AssemblyName>
76
<RootNamespace>System.IO.Abstractions.Tests</RootNamespace>
8-
<IsPackable>false</IsPackable>
9-
<IsTestable>true</IsTestable>
107
</PropertyGroup>
8+
119
<ItemGroup>
1210
<ProjectReference Include="..\..\src\TestableIO.System.IO.Abstractions.Wrappers\TestableIO.System.IO.Abstractions.Wrappers.csproj" />
1311
</ItemGroup>
12+
1413
<ItemGroup>
15-
<PackageReference Include="coverlet.collector">
16-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17-
<PrivateAssets>all</PrivateAssets>
18-
</PackageReference>
19-
<PackageReference Include="GitHubActionsTestLogger" />
20-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
21-
<PackageReference Include="Moq" />
22-
<PackageReference Include="NUnit" />
23-
<PackageReference Include="NUnit.Analyzers" />
24-
<PackageReference Include="NUnit3TestAdapter" />
2514
<PackageReference Include="Snapshooter.NUnit" />
2615
</ItemGroup>
27-
<PropertyGroup>
28-
<!--
29-
Allow deprecated binary formatter functionality on .NET 8 so that we can test it
30-
-->
31-
<EnableUnsafeBinaryFormatterSerialization Condition="'$(TargetFramework)' == 'net8.0'">true</EnableUnsafeBinaryFormatterSerialization>
32-
</PropertyGroup>
16+
3317
</Project>

0 commit comments

Comments
 (0)