VOOZH about

URL: https://www.nuget.org/packages/MockMe/

⇱ NuGet Gallery | MockMe 1.1.2




👁 Image
MockMe 1.1.2

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

👁 Coverage Status

What is it?

MockMe is a library for mocking dependencies in your unit test projects. Unlike other libraries that can only mock interfaces and virtual methods, MockMe can mock sealed classes and non-virtual methods.

Getting Started

Imagine you have the following repository class

sealed class MyRepo
{
 public int ExpensiveDatabaseCall() => // some code;
}

Download the MockMe NuGet package, then the source generators and the "MockMe.Mock" type will be available in your project. Then you can customize the behavior of the repository class as below.

using MockMe;

// use this syntax to trigger the source generator to make a mock of the provided type
// the 'mock' object will have 3 properties: Setup, Assert, and MockedObject
// hint: rebuild test project after writing this line or IntelliSense may not work correctly
var mock = Mock.Me(default(MyRepo)); 

// the mock.Setup object has an identical interface to the original object
// from there you can configure method behavior with 'Returns', 'Callback', 'Throws', etc
mock.Setup.ExpensiveDatabaseCall().Returns(99);

// the mock.MockedObject is a special instance of the mocked type which has the modified behavior
// other instances of the mocked type will have the original behavior
MyRepo myRepo = mock.MockedObject;
int result = myRepo.ExpensiveDatabaseCall();

Assert.Equal(99, result);

// the mock.Assert object also has an identical interface to the original object.
// you can use it to assert certain mock behaviors
mock.Assert.ExpensiveDatabaseCall().WasCalled();

Check out the Wiki for more examples.

Give it a Star

If you like this project, please give it a star!

Product Versions Compatible and additional computed target framework versions.
.NET net6.0 net6.0 is compatible.  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 was computed.  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 was computed.  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. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.2 2,102 1/31/2025
1.1.0 157 1/23/2025
1.0.4 351 1/7/2025
1.0.3 175 1/6/2025
1.0.2 191 1/4/2025
1.0.0 202 12/4/2024