Summary
Replace NSubstitute with TUnit.Mocks as the mocking library used in NetEvolve.Logging.XUnit.Tests.Unit.
NSubstitute is currently referenced only in NetEvolve.Logging.XUnit.Tests.Unit and used in 1 file for creating mocks/substitutes:
Note: unlike the other repositories in the org, this test project does not use TUnit yet, so this migration also requires introducing TUnit(.Mocks) as a new dependency rather than just extending an existing one. Confirm whether this repo should move to TUnit as the test framework as part of this change, or only adopt TUnit.Mocks alongside the existing framework.
Motivation / Benefits
- One framework instead of two:
TUnit.Mocks is part of the TUnit ecosystem used across the rest of the dailydevops org for the test runner, assertions, and data-driven tests. Consolidating removes a second, independently-versioned dependency (NSubstitute + Castle.Core).
- Source-generated mocks, no runtime proxying: NSubstitute relies on Castle DynamicProxy to generate proxy types at runtime via reflection/IL emission.
TUnit.Mocks generates mock implementations at compile time via a Roslyn source generator, giving faster test startup and compile-time errors instead of runtime failures.
- Full AOT/trimming compatibility.
- Smaller dependency surface: drops the transitive dependency on Castle.Core.
Scope
- Decide on the test framework question above (TUnit migration vs.
TUnit.Mocks-only).
- Add
TUnit.Mocks package reference to tests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj.
- Migrate the
Substitute.For<T>() usage in XUnitLoggerTests.cs to the equivalent TUnit.Mocks API.
- Remove the
NSubstitute package reference once migration is complete.
Reference
See dailydevops/healthchecks#2049 for the equivalent migration in that repository, including the rationale for this org-wide change.
Summary
Replace NSubstitute with
TUnit.Mocksas the mocking library used inNetEvolve.Logging.XUnit.Tests.Unit.NSubstitute is currently referenced only in
NetEvolve.Logging.XUnit.Tests.Unitand used in 1 file for creating mocks/substitutes:XUnitLoggerTests.csNote: unlike the other repositories in the org, this test project does not use TUnit yet, so this migration also requires introducing TUnit(.Mocks) as a new dependency rather than just extending an existing one. Confirm whether this repo should move to TUnit as the test framework as part of this change, or only adopt
TUnit.Mocksalongside the existing framework.Motivation / Benefits
TUnit.Mocksis part of the TUnit ecosystem used across the rest of thedailydevopsorg for the test runner, assertions, and data-driven tests. Consolidating removes a second, independently-versioned dependency (NSubstitute + Castle.Core).TUnit.Mocksgenerates mock implementations at compile time via a Roslyn source generator, giving faster test startup and compile-time errors instead of runtime failures.Scope
TUnit.Mocks-only).TUnit.Mockspackage reference totests/NetEvolve.Logging.XUnit.Tests.Unit/NetEvolve.Logging.XUnit.Tests.Unit.csproj.Substitute.For<T>()usage inXUnitLoggerTests.csto the equivalentTUnit.MocksAPI.NSubstitutepackage reference once migration is complete.Reference
See dailydevops/healthchecks#2049 for the equivalent migration in that repository, including the rationale for this org-wide change.