VOOZH about

URL: https://www.nuget.org/packages/aweXpect.Mockolate

⇱ NuGet Gallery | aweXpect.Mockolate 3.1.0




👁 Image
aweXpect.Mockolate 3.1.0

Prefix Reserved
dotnet add package aweXpect.Mockolate --version 3.1.0
 
 
NuGet\Install-Package aweXpect.Mockolate -Version 3.1.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="aweXpect.Mockolate" Version="3.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="aweXpect.Mockolate" Version="3.1.0" />
 
Directory.Packages.props
<PackageReference Include="aweXpect.Mockolate" />
 
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 aweXpect.Mockolate --version 3.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: aweXpect.Mockolate, 3.1.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 aweXpect.Mockolate@3.1.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=aweXpect.Mockolate&version=3.1.0
 
Install as a Cake Addin
#tool nuget:?package=aweXpect.Mockolate&version=3.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

aweXpect.Mockolate

👁 Changelog

👁 Nuget
👁 Coverage
👁 Mutation testing badge

Expectations to verify interactions with mocks from Mockolate.

Features

Interaction count

Verify that a method was called a specific number of times:

var sut = IMyService.CreateMock();
sut.MyMethod();

await That(sut.Mock.Verify.MyMethod()).Once(); // Exactly once
await That(sut.Mock.Verify.MyMethod()).Twice(); // Exactly twice
await That(sut.Mock.Verify.MyMethod()).Never(); // Never called
await That(sut.Mock.Verify.MyMethod()).AtLeastOnce(); // At least once
await That(sut.Mock.Verify.MyMethod()).AtLeastTwice(); // At least twice
await That(sut.Mock.Verify.MyMethod()).AtLeast(3.Times()); // At least 3 times
await That(sut.Mock.Verify.MyMethod()).AtMostOnce(); // At most once
await That(sut.Mock.Verify.MyMethod()).AtMostTwice(); // At most twice
await That(sut.Mock.Verify.MyMethod()).AtMost(4.Times()); // At most 4 times
await That(sut.Mock.Verify.MyMethod()).Exactly(2.Times()); // Exactly 2 times
await That(sut.Mock.Verify.MyMethod()).Between(2).And(5.Times()); // Between 2 and 5 times
Asynchronous verification

With Within(TimeSpan timeout), you can check whether the expected number of calls occurred within a given time interval. This is useful for asynchronous or delayed invocations in the background.

Within and WithCancellation are available on AtLeast*, Once, Twice, Exactly, and Between. They are not available on Never or AtMost*, since an upper bound cannot be confirmed by waiting longer.

var sut = IMyService.CreateMock();

// Start asynchronous calls, e.g., in a Task
Task.Run(async () =>
{
 await Task.Delay(500);
 sut.MyMethod();
});

// Verifies that MyMethod was called at least once within 1 second
await That(sut.Mock.Verify.MyMethod())
 .AtLeastOnce()
 .Within(TimeSpan.FromSeconds(1));

Instead of a fixed time span, you can also provide a CancellationToken to limit how long the verification should wait for the expected interactions:

var token = new CancellationTokenSource(TimeSpan.FromSeconds(1)).Token;

// Verifies that MyMethod was called at least once within 1 second
await That(sut.Mock.Verify.MyMethod())
 .AtLeastOnce()
 .WithCancellation(token);

Interaction order

Verify that methods were called in a specific sequence:

var sut = IMyService.CreateMock();
sut.MyMethod(1);
sut.MyMethod(2);
sut.MyMethod(3);
sut.MyMethod(4);

// Verifies MyMethod(1), then MyMethod(2), then MyMethod(4) were called in order
await That(sut.Mock.Verify.MyMethod(It.Is(1))).Then(
 m => m.MyMethod(It.Is(2)),
 m => m.MyMethod(It.Is(4))
);

Additional Verifications

All interactions are verified

With AllInteractionsAreVerified you can check whether all interactions with the mock have actually been verified. This helps to detect unintended or forgotten calls.

var sut = IMyService.CreateMock();
sut.MyMethod(1);
sut.MyMethod(2);

await That(sut.Mock.Verify.MyMethod(It.IsAny<int>())).AtLeastOnce();
 // Succeeds, because the verification applies to both method calls.
await That(sut.Mock.Verify).AllInteractionsAreVerified();
All setups are used

With AllSetupsAreUsed you can check whether all defined setups on the mock have actually been used. This ensures that no setup configurations remain unused.

var sut = IMyService.CreateMock();
sut.Mock.Setup.MyMethod(It.Is(1)).Returns(10);
sut.Mock.Setup.MyMethod(It.Is(2)).Returns(20);

sut.MyMethod(1);

// Fails, because the setup for MyMethod(2) was never used.
await That(sut.Mock.Verify).AllSetupsAreUsed();

Web Extensions

Web extensions require .NET 8.0 or later.

JSON Content

You can precisely verify JSON content in HTTP requests during your tests. This feature is especially useful for testing HTTP clients and web APIs.

// Verifies that a request was sent with a JSON body equivalent to { "foo": 1, "bar": "baz" }
httpClient.Mock.Setup
 .PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJsonMatching(new { foo = 1, bar = "baz" }))
 .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));

// You can also provide a string representation of the JSON, and it ignores formatting differences or property order
httpClient.Mock.Setup
 .PostAsync(It.IsAny<Uri>(), It.IsHttpContent().WithJson("{\"bar\": \"baz\", \"foo\": 1}"))
 .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));

By default, additional properties in the actual JSON are ignored. Use IgnoringAdditionalProperties(false) to require an exact match:

// Fails if the request body contains any property other than `foo` and `bar`
httpClient.Mock.Setup
 .PostAsync(It.IsAny<Uri>(), It.IsHttpContent()
 .WithJsonMatching(new { foo = 1, bar = "baz" })
 .IgnoringAdditionalProperties(false))
 .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));
Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on aweXpect.Mockolate:

Repository Stars
TestableIO/System.IO.Abstractions
Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
Version Downloads Last Updated
3.1.0 1,106 5/10/2026
3.0.0 767 4/30/2026
3.0.0-pre.1 1,853 4/26/2026
2.3.0 1,945 4/3/2026
2.2.0 120 4/3/2026
2.2.0-pre.1 179 4/2/2026
2.0.0 1,222 3/25/2026
2.0.0-pre.3 64 3/24/2026
2.0.0-pre.2 62 3/24/2026
2.0.0-pre.1 65 3/22/2026
1.3.0 836 3/22/2026
1.2.0 967 3/6/2026
1.1.1 908 2/10/2026
1.1.0 334 2/8/2026
1.0.0 1,611 1/19/2026
0.10.0 121 1/18/2026
0.9.0 2,392 12/5/2025
0.8.0 217 12/4/2025
0.7.0 613 12/1/2025
0.6.0 592 11/24/2025
Loading failed