Mockolate 3.2.0
Prefix Reserveddotnet add package Mockolate --version 3.2.0
NuGet\Install-Package Mockolate -Version 3.2.0
<PackageReference Include="Mockolate" Version="3.2.0" />
<PackageVersion Include="Mockolate" Version="3.2.0" />
<PackageReference Include="Mockolate" />
paket add Mockolate --version 3.2.0
#r "nuget: Mockolate, 3.2.0"
#:package Mockolate@3.2.0
#addin nuget:?package=Mockolate&version=3.2.0
#tool nuget:?package=Mockolate&version=3.2.0
Mockolate

Mockolate is a modern, strongly-typed, AOT-compatible mocking library for .NET, powered by source generators. It enables fast, compile-time validated mocking with .NET Standard 2.0, .NET 8, .NET 10 and .NET Framework 4.8.
- Source generator-based: No runtime proxy generation.
- Fast: Direct dispatch with no reflection or dynamic proxies.
- Strongly-typed: Compile-time safety and IntelliSense support.
- AOT compatible: Works with Native AOT and trimming.
- Modern C#: First-class support for ref structs, static interface members, and current language features.
Why Mockolate
| Reflection-based mocks (Moq, NSubstitute, …) | Mockolate | |
|---|---|---|
| AOT / trimming | not supported | supported |
| Validation | runtime exceptions | analyzers + compile errors |
| Setup API | Expression<Func<…>> trees |
regular method calls |
| Hot path | dynamic-proxy dispatch | direct dispatch |
For side-by-side setup, usage, and verification syntax against Moq, NSubstitute, and FakeItEasy, see the full code comparison; for performance, see the benchmarks.
Already on Moq or NSubstitute? The companion package Mockolate.Migration
ships analyzers and code fixers that translate common Moq and NSubstitute patterns to Mockolate syntax in-place: point it
at an existing test project and apply the suggested fixes.
Installation
Install the .NET 10 SDK. Mockolate leverages C# 14 extension members (the projects can still target any supported framework). Then add the package:
dotnet add package Mockolate
Quick Start
using Mockolate;
public interface IChocolateDispenser
{
bool Dispense(string type, int amount);
}
// Create a mock
IChocolateDispenser sut = IChocolateDispenser.CreateMock();
// Setup: Dispense returns true for any Dark chocolate request
sut.Mock.Setup.Dispense("Dark", It.IsAny<int>()).Returns(true);
// Act
bool success = sut.Dispense("Dark", 4);
// Verify
sut.Mock.Verify.Dispense("Dark", It.IsAny<int>()).Once();
Documentation
Full reference docs at docs.testably.org/Mockolate:
- Create mocks
- Setup: properties, methods, indexers, parameter matching
- Mock events
- Verify interactions
- Advanced features: protected members, static interface members, callbacks, monitors, scenarios, unexpected-interaction checks
- Special types:
HttpClient, delegates
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Memory (>= 4.6.3)
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Mockolate:
| Package | Downloads |
|---|---|
|
aweXpect.Mockolate
Expectations to verify interactions with mocks from Mockolate. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Mockolate:
| Repository | Stars |
|---|---|
|
thomhurst/TUnit
A modern, fast and flexible .NET testing framework
|
|
|
TestableIO/System.IO.Abstractions
Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.0 | 0 | 5/11/2026 |
| 3.1.0 | 1,046 | 5/2/2026 |
| 3.1.0-pre.1 | 43 | 5/1/2026 |
| 3.0.0 | 993 | 4/30/2026 |
| 3.0.0-pre.6 | 47 | 4/30/2026 |
| 3.0.0-pre.5 | 47 | 4/29/2026 |
| 3.0.0-pre.4 | 57 | 4/27/2026 |
| 3.0.0-pre.3 | 68 | 4/26/2026 |
| 3.0.0-pre.2 | 517 | 4/26/2026 |
| 3.0.0-pre.1 | 70 | 4/22/2026 |
| 2.5.0-pre.5 | 56 | 4/20/2026 |
| 2.5.0-pre.4 | 54 | 4/19/2026 |
| 2.5.0-pre.3 | 54 | 4/19/2026 |
| 2.5.0-pre.2 | 48 | 4/18/2026 |
| 2.5.0-pre.1 | 44 | 4/18/2026 |
| 2.4.0 | 4,285 | 4/7/2026 |
| 2.3.0 | 859 | 4/4/2026 |
| 2.2.0 | 495 | 4/3/2026 |
| 2.2.0-pre.2 | 91 | 4/3/2026 |
| 2.2.0-pre.1 | 81 | 4/2/2026 |