Skip to content

Commit a0b3dc0

Browse files
committed
Code review suggestions plus refactoring
1 parent 55ed3c7 commit a0b3dc0

File tree

15 files changed

+45
-84
lines changed

15 files changed

+45
-84
lines changed

src/Directory.Build.props

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<Product>NUnit 4 Runner and Engine</Product>
2626
<Copyright>Copyright (c) 2022 Charlie Poole, Rob Prouse</Copyright>
2727
<Trademark>NUnit is a trademark of NUnit Software</Trademark>
28+
<!-- Keys for Friend Assemblies -->
29+
<NUnitPublicKey>002400000480000094000000060200000024000052534131000400000100010031eea370b1984bfa6d1ea760e1ca6065cee41a1a279ca234933fe977a096222c0e14f9e5a17d5689305c6d7f1206a85a53c48ca010080799d6eeef61c98abd18767827dc05daea6b6fbd2e868410d9bee5e972a004ddd692dec8fa404ba4591e847a8cf35de21c2d3723bc8d775a66b594adeb967537729fe2a446b548cd57a6</NUnitPublicKey>
30+
<NSubstitutePublicKey>0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7</NSubstitutePublicKey>
2831
</PropertyGroup>
2932

3033
</Project>
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Directory.Build.props for Extensibility -->
22
<Project>
33

4-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
5-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Nullable.props', '$(MSBuildThisFileDirectory)../'))" />
6-
4+
<Import Project="$(MSBuildThisFileDirectory)../Directory.Build.props" />
5+
<Import Project="$(MSBuildThisFileDirectory)../Nullable.props" />
6+
77
</Project>

src/Extensibility/nunit.extensibility.api/nunit.extensibility.api.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<RootNamespace>NUnit.Extensibility</RootNamespace>
55
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
6+
<!-- TODO: Get rid of obsolete BinaryFormatter -->
67
<NoWarn>$(NoWarn);SYSLIB0011</NoWarn>
78
</PropertyGroup>
89

src/Extensibility/nunit.extensibility/nunit.extensibility.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<RootNamespace>NUnit.Extensibility</RootNamespace>
55
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
6+
<!-- TODO: Get rid of obsolete BinaryFormatter -->
67
<NoWarn>$(NoWarn);SYSLIB0011</NoWarn>
78
</PropertyGroup>
89

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Directory.Build.props for NUnitConsole -->
22
<Project>
33

4-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
5-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Nullable.props', '$(MSBuildThisFileDirectory)../'))" />
6-
4+
<Import Project="$(MSBuildThisFileDirectory)../Directory.Build.props" />
5+
<Import Project="$(MSBuildThisFileDirectory)../Nullable.props" />
6+
77
</Project>

src/NUnitConsole/nunit4-console/Properties/AssemblyInfo.cs

-15
This file was deleted.

src/NUnitConsole/nunit4-console/nunit4-console.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<TargetFrameworks>net462</TargetFrameworks>
88
</PropertyGroup>
99

10+
<ItemGroup>
11+
<InternalsVisibleTo Include="nunit4-console.tests, PublicKey=$(NUnitPublicKey)" />
12+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKey=$(NSubstitutePublicKey)" />
13+
</ItemGroup>
14+
1015
<PropertyGroup>
1116
<AssemblyTitle>NUnit Console Runner ($(TargetFramework))</AssemblyTitle>
1217
<Description>The standard command-line runner for NUnit</Description>

src/NUnitConsole/nunit4-netcore-console/Properties/AssemblyInfo.cs

-15
This file was deleted.

src/NUnitConsole/nunit4-netcore-console/nunit4-netcore-console.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
<TargetFrameworks>net8.0</TargetFrameworks>
88
</PropertyGroup>
99

10+
<ItemGroup>
11+
<InternalsVisibleTo Include="nunit4-console.tests, PublicKey=$(NUnitPublicKey)" />
12+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKey=$(NSubstitutePublicKey)" />
13+
</ItemGroup>
14+
1015
<PropertyGroup>
1116
<AssemblyTitle>NUnit NetCore Console Runner ($(TargetFramework))</AssemblyTitle>
1217
<Description>The dotnet command-line runner for NUnit</Description>

src/NUnitEngine/Directory.Build.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- Directory.Build.props for NUnitEngine -->
22
<Project>
33

4-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
5-
<Import Project="$([MSBuild]::GetPathOfFileAbove('Nullable.props', '$(MSBuildThisFileDirectory)../'))" />
4+
<Import Project="$(MSBuildThisFileDirectory)../Directory.Build.props" />
5+
<Import Project="$(MSBuildThisFileDirectory)../Nullable.props" />
66

77
</Project>

src/NUnitEngine/nunit.engine.core/Properties/AssemblyInfo.cs

-15
This file was deleted.

src/NUnitEngine/nunit.engine.core/nunit.engine.core.csproj

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
<PropertyGroup>
44
<RootNamespace>NUnit.Engine</RootNamespace>
55
<TargetFrameworks>net462;netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
6-
<NoWarn>$(NoWarn);SYSLIB0011</NoWarn><!-- TODO: Get rid of obsolete stuff -->
6+
<!-- TODO: Get rid of obsolete BinaryFormatter -->
7+
<NoWarn>$(NoWarn);SYSLIB0011</NoWarn>
78
</PropertyGroup>
89

10+
<ItemGroup>
11+
<InternalsVisibleTo Include="nunit.engine.core.tests, PublicKey=$(NUnitPublicKey)" />
12+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKey=$(NSubstitutePublicKey)" />
13+
</ItemGroup>
14+
915
<PropertyGroup>
1016
<AssemblyTitle>NUnit Engine Core</AssemblyTitle>
1117
<Description>Common code used by both the engine and agents</Description>

src/NUnitEngine/nunit.engine.tests/Runners/WorkItemTrackerTests.cs

+10-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void CreateTracker()
1919
{
2020
_tracker = new WorkItemTracker();
2121
_listener = _tracker;
22-
_pendingNotices = new List<string>();
22+
_pendingNotices = [];
2323
}
2424

2525
[TestCaseSource(nameof(AllItemsComplete))]
@@ -29,7 +29,7 @@ public void WhenAllItemsComplete_NoAdditionalReportsAreIssued(ReportSequence rep
2929

3030
_tracker.SendPendingTestCompletionEvents(this);
3131

32-
Assert.That(_pendingNotices.Count, Is.EqualTo(0));
32+
Assert.That(_pendingNotices, Is.Empty);
3333
}
3434

3535
[TestCaseSource(nameof(SomeItemsIncomplete))]
@@ -42,14 +42,9 @@ public void WhenItemsFailToComplete_ReportsAreIssued(ReportSequence reports, Rep
4242
Assert.That(_pendingNotices, Is.EqualTo(expectedNotices.Reports));
4343
}
4444

45-
public class ReportSequence
45+
public class ReportSequence(params string[] reports)
4646
{
47-
public ReportSequence(params string[] reports)
48-
{
49-
Reports = reports;
50-
}
51-
52-
public string[] Reports { get; }
47+
public string[] Reports { get; } = reports;
5348

5449
public void SendTo(ITestEventListener listener)
5550
{
@@ -79,8 +74,8 @@ public void SendTo(ITestEventListener listener)
7974
static readonly string CANCEL_FIXTURE_1 = END_FIXTURE_1.Replace("/>", CANCEL_INFO);
8075
static readonly string CANCEL_FIXTURE_2 = END_FIXTURE_2.Replace("/>", CANCEL_INFO);
8176

82-
static TestCaseData[] AllItemsComplete = new TestCaseData[]
83-
{
77+
static readonly TestCaseData[] AllItemsComplete =
78+
[
8479
new TestCaseData(new ReportSequence(
8580
START_ASSEMBLY, START_NS_1, START_NS_2,
8681
START_FIXTURE_1, END_FIXTURE_1,
@@ -91,10 +86,10 @@ public void SendTo(ITestEventListener listener)
9186
START_FIXTURE_1, START_FIXTURE_2,
9287
END_FIXTURE_1, END_FIXTURE_2,
9388
END_NS_2, END_NS_1, END_ASSEMBLY ))
94-
};
89+
];
9590

96-
static TestCaseData[] SomeItemsIncomplete = new TestCaseData[]
97-
{
91+
static readonly TestCaseData[] SomeItemsIncomplete =
92+
[
9893
new TestCaseData(
9994
new ReportSequence(
10095
START_ASSEMBLY, START_NS_1, START_NS_2,
@@ -116,7 +111,7 @@ public void SendTo(ITestEventListener listener)
116111
START_FIXTURE_2 ), // Both fixtures hang!
117112
new ReportSequence(
118113
CANCEL_FIXTURE_2, CANCEL_FIXTURE_1, CANCEL_NS_2, CANCEL_NS_1, CANCEL_ASSEMBLY)),
119-
};
114+
];
120115

121116
void ITestEventListener.OnTestEvent(string report)
122117
{

src/NUnitEngine/nunit.engine/Properties/AssemblyInfo.cs

-15
This file was deleted.

src/NUnitEngine/nunit.engine/nunit.engine.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<TargetFrameworks>net462;net8.0</TargetFrameworks>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<InternalsVisibleTo Include="nunit.engine.tests, PublicKey=$(NUnitPublicKey)" />
10+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKey=$(NSubstitutePublicKey)" />
11+
</ItemGroup>
12+
813
<PropertyGroup>
914
<AssemblyTitle>NUnit Engine ($(TargetFramework))</AssemblyTitle>
1015
<Description>Provides for loading, exploring and running NUnit tests</Description>

0 commit comments

Comments
 (0)