Zonkey.Mocks
7.0.3
dotnet add package Zonkey.Mocks --version 7.0.3
NuGet\Install-Package Zonkey.Mocks -Version 7.0.3
<PackageReference Include="Zonkey.Mocks" Version="7.0.3" />
<PackageVersion Include="Zonkey.Mocks" Version="7.0.3" />
<PackageReference Include="Zonkey.Mocks" />
paket add Zonkey.Mocks --version 7.0.3
#r "nuget: Zonkey.Mocks, 7.0.3"
#:package Zonkey.Mocks@7.0.3
#addin nuget:?package=Zonkey.Mocks&version=7.0.3
#tool nuget:?package=Zonkey.Mocks&version=7.0.3
Zonkey.Mocks
Mock implementations of core ADO.NET classes for unit testing Zonkey-based data access code without a real database.
Installation
dotnet add package Zonkey.Mocks
What's Inside
- MockDbConnection -- mock connection with configurable command setup
- MockDbCommand -- mock command with delegate-based behavior (
DoExecuteReader,DoExecuteScalar,DoExecuteNonQuery) - MockDbDataReader -- mock reader backed by DataTable, collections, or dictionaries
- MockDbParameter / MockDbParameterCollection -- mock parameter objects
- MockDbTransaction -- mock transaction with state tracking (
Uncomitted,Comitted,RolledBack)
Quick Example
using Zonkey.Mocks;
var connection = new MockDbConnection();
connection.SetupCommandFunc = cmd =>
{
cmd.DoExecuteReader = c =>
{
var dt = new DataTable();
dt.Columns.Add("id", typeof(int));
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("price", typeof(decimal));
dt.Rows.Add(1, "Classic Tee", 24.99m);
return dt;
};
};
connection.Open();
var adapter = new DataClassAdapter<Product>(connection);
var product = await adapter.GetOne(p => p.Id == 1);
// product.Name == "Classic Tee"
Use Cases
- Test data mapping logic (column-to-property)
- Verify SQL generation and parameter binding
- Test save behavior (insert vs update detection)
- Test transaction state management
- Test error handling paths
Target Frameworks
- .NET 8.0
- .NET 10.0
- .NET Framework 4.8
Documentation
See the testing guide for detailed patterns and the full documentation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 7.0.3 | 79 | 8/13/2026 |
| 7.0.1 | 89 | 8/6/2026 |
| 7.0.0 | 94 | 7/30/2026 |
| 6.0.0.1600 | 626 | 8/14/2022 |
| 5.0.0 | 1,284 | 7/29/2018 |
Zonkey 7.0.3 makes SqlFilter.IN's Value setter functional (replacing the IN list with construction-time normalization; a scalar becomes a single-element list) and caches the collection-parameter typed array so ToString and AddToCommandParams scan the list once.
Zonkey 7.0.2 adds SqlFilter.IN for the composable filter surface, with the same semantics as the where-expression Contains() translation: an empty or all-null list renders a commented "1 = 0", a single value collapses to an equality, and a multi-value list binds as one typed-array collection parameter on dialects that support it (PostgreSQL: "field = ANY(:pN)") or as individually suffixed parameters ("field IN (:pN_0, :pN_1, ...)") everywhere else.
Zonkey 7.0.1 adds symmetric DateOnly/TimeOnly conversions: providers that surface date/time columns as DateOnly/TimeOnly (notably Npgsql 10) now fill DateTime, TimeSpan, and string properties correctly on both materialization paths, DateOnly/TimeOnly property values round-trip to all supported databases, date/time-ish values destined for string properties render as round-trip ISO strings instead of culture-specific text, and TimeSpan properties now fill from string (standard "d.hh:mm:ss" TimeSpan.Parse forms, e.g. text-backed SQLite time columns) and DateTime (time-of-day) sources.
7.0.1 also reworks IN-list translation: a single value now renders as "col = @p0" rather than "col IN (@p0)"; PostgreSQL binds a list of two or more as one array parameter ("col = ANY($0)") at any size, removing the parameter-count ceiling there; a null in the list never matches, following SQL IN semantics rather than C# Contains semantics; and an empty or all-null list renders a commented "1 = 0". SplitList() is obsolete on .NET 6 and later in favour of System.Linq's Chunk(), and remains supported on .NET Framework 4.8, which has no Chunk. See the "Translation policy" section of docs/querying.md.
Zonkey 7.0 is a major release with breaking changes. Packages now target .NET 8, .NET 10, and .NET Framework 4.8 (Zonkey.Text targets .NET Standard 2.0 and .NET Framework 4.8), and assemblies are no longer strong-name signed. Applications on .NET 7 or earlier (including .NET 5/6 and .NET Core), on .NET Framework before 4.8, or requiring strong-named assemblies should stay on the latest v6.x release. See https://github.com/kellybirr/zonkey for full documentation, and see the repository README's "Breaking Changes from v6.x" section for the complete list of API changes (such as WithTransaction) and WHERE-expression behavior changes. FillRange paging on SQL Server now uses OFFSET/FETCH and requires SQL Server 2012 or later.