Add no-DB unit tests using pengdows.crud.fakeDb, reaching 92.1% Dapper.dll coverage - #2199
Add no-DB unit tests using pengdows.crud.fakeDb, reaching 92.1% Dapper.dll coverage#2199alaricd wants to merge 1 commit into
Conversation
|
@mgravell — build is now green. 775 pure unit tests, no live database required, using pengdows.crud.fakeDb as a fake ADO.NET provider. Test-only dependency, zero production code changes. Happy to address any feedback. |
|
this looks like a lot of useful work; there are currently merge conflicts - I can't resolve them without push access; can you either add external PR push access, or help me resolve them? |
|
I will fix them |
|
@mgravell all the merge conflicts are resolved. |
|
Small correction to my earlier “zero production changes” statement: the added coverage exposed one real Dapper bug. PackListParameters was calling LookupDbType(...) for expanded list parameters and receiving the registered ITypeHandler, but then discarding it and assigning each value through SanitizeParameterValue(...) instead. The fix preserves the handler and calls handler.SetValue(...) for each expanded list item. This makes custom type handlers behave consistently between scalar parameters and IN @ids-style collection parameters. I traced this path back to the August 5, 2015 commit that originally added type-map support for collection parameters; that implementation already retrieved the handler without using it. So this appears to be an approximately 11-year-old latent bug, not a recent regression. The only other production-source change is changing DefaultTypeMap.GetSettableFields from private to internal for testability; its behavior is unchanged. The new regression test specifically verifies that ITypeHandler.SetValue is invoked for every expanded collection element. |
…r.dll coverage
Introduces 859 pure unit tests that run without a live database connection,
using pengdows.crud.fakeDb v2.0.5 as a fake ADO.NET provider, alongside the
existing integration test suite.
Coverage (net8.0, this test set only):
dotnet-coverage collect --output coverage.xml --output-format cobertura \
-- dotnet test tests/Dapper.Tests/Dapper.Tests.csproj -f net8.0 \
--filter "FullyQualifiedName~FakeDb"
reportgenerator -reports:coverage.xml -targetdir:covreport -reporttypes:TextSummary
Dapper.dll overall: 92.1%
Dapper.SqlMapper: 91.8%
Scope is intentionally limited to the fakeDb-based test substrate: no
target-framework, SDK, or unrelated dependency changes, and no production
visibility changes. DefaultTypeMap.GetSettableFields stays private; its
mapping behavior is exercised through the public Query<T> API instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HGpTXegyVtX7cNR3vnuL1z
5cdfe25 to
9efafaa
Compare
Introduces 859 pure unit tests that run without a live database connection,
using pengdows.crud.fakeDb v2.0.5 as a fake ADO.NET provider, alongside the
existing integration test suite.
Coverage (net8.0, this test set only), reproducible with:
Scope is limited to the fakeDb-based test substrate: no target-framework,
SDK, or unrelated dependency changes, and no production visibility changes.
(The PackListParameters/TypeHandler behavioral fix that was previously bundled
here has been split out to its own PR: #TBD.)
Key areas covered by new FakeDbTests.*.cs files: