chore: Migrate NSubstitute to TUnit.Mocks in Tests.Unit - #563
Conversation
Migrates IDataReaderExtensionsTests.cs and IDataRecordExtensionsTests.cs
to TUnit.Mocks, consolidating onto the TUnit ecosystem already used as
the test framework.
DbDataReaderExtensionsTests.cs stays on NSubstitute: TUnit.Mocks 1.62.0's
source generator emits CS0205 ("Cannot call an abstract base member")
when mocking DbDataReader, because its abstract this[int]/this[string]
indexers have no base implementation to forward to. This mirrors the
scoped-exception approach taken in dailydevops/healthchecks#2049 for
similar upstream generator limitations.
Also drops the unused NSubstitute reference from
NetEvolve.Extensions.Data.Tests.PublicApi.csproj.
Closes #555
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ception Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #563 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 114 114
Branches 28 28
=========================================
Hits 114 114 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
IDataReaderExtensionsTests.csandIDataRecordExtensionsTests.csinNetEvolve.Extensions.Data.Tests.Unitfrom NSubstitute to TUnit.Mocks, consolidating onto the TUnit ecosystem already used as this project's test framework.Scoped exception
DbDataReaderExtensionsTests.csstays on NSubstitute. TUnit.Mocks 1.62.0 (currently the latest) generates a mock implementation forDbDataReaderthat fails to compile:DbDataReader's indexers are abstract with no base implementation, so the generator's strategy of forwarding tobase[...]doesn't compile. This is a source-generator limitation, not something fixable from test code — confirmed with a minimal, standalone repro, filed upstream as thomhurst/TUnit#6516. TheNSubstitutepackage reference and comment in the csproj document this as a scoped, removable exception (linking that issue), mirroring the approach taken for similar generator limitations in dailydevops/healthchecks#2049 / #2051.Also removes the unused
NSubstitutepackage reference fromNetEvolve.Extensions.Data.Tests.PublicApi.csproj(dead reference, no file in that project used it).Test plan
dotnet build(whole solution, all TFMs) — 0 warnings, 0 errorsdotnet testforNetEvolve.Extensions.Data.Tests.Unitacross net8.0/net9.0/net10.0 — 921/921 passedIDataRecordExtensionsTests.CreateTestRecord()helper's overlapping matcher setups (Any<int>()general fallback + exact-value/predicate overrides) preserve NSubstitute's "later matching setup wins" semantics — all edge-case theory tests (index 0, 1, negative) pass🤖 Generated with Claude Code