Zonkey.Mocks 7.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Zonkey.Mocks --version 7.0.0
                    
NuGet\Install-Package Zonkey.Mocks -Version 7.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zonkey.Mocks" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zonkey.Mocks" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Zonkey.Mocks" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zonkey.Mocks --version 7.0.0
                    
#r "nuget: Zonkey.Mocks, 7.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zonkey.Mocks@7.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zonkey.Mocks&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Zonkey.Mocks&version=7.0.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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 86 8/13/2026
7.0.1 90 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 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.