Mocking is the act of replacing a function with a fake copy and optionally, configuring it to return some predefined data. The primary use case for mocking is unit testing. Mocking frameworks allow you to replace a specific call to a class or method with a behavior you define. Thanks to this ability, you can easily test units of code in isolation without messing up their dependencies These are the 11 best C# Mock libraries in 2022, NSubstitute - A friendly substitute for .NET mocking libraries; FakeItEasy - The easy mocking library for .NET; WireMock.Net - flexible library; pact-net - .NET version of Pact; moq.spikes - The most popular and friendly mocking framework for .NET.
NSubstituteby nsubstitute
A friendly substitute for .NET mocking libraries.
NSubstituteby nsubstitute
C# 1952 Version:v5.0.0 License: Others (Non-SPDX)
FakeItEasyby FakeItEasy
The easy mocking library for .NET
FakeItEasyby FakeItEasy
C# 1420 Version:8.0.0-alpha.1 License: Permissive (MIT)
WireMock.Netby WireMock-Net
WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
WireMock.Netby WireMock-Net
C# 1108 Version:1.5.27 License: Permissive (Apache-2.0)
pact-netby pact-foundation
.NET version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
pact-netby pact-foundation
C# 712 Version:4.6.0-beta.1 License: Permissive (MIT)
MockQueryableby romantitov
Mocking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
MockQueryableby romantitov
C# 599 Version:v7.0 License: Permissive (MIT)
rhino-mocksby ayende
Dynamic Mocking Framework for .NET
rhino-mocksby ayende
C# 254 Version:Current License: Permissive (BSD-3-Clause)
moq.spikesby moq
The most popular and friendly mocking framework for .NET
moq.spikesby moq
C# 251 Version:Current License: Permissive (Apache-2.0)
Moq.AutoMockerby moq
An auto-mocking IoC container for Moq
Moq.AutoMockerby moq
C# 334 Version:v3.5.0 License: Permissive (MIT)
entity-framework-core-mockby cup-of-tea-dot-be
Easy Mock wrapper for mocking EFCore5 DbContext and DbSet using Moq or NSubstitute
entity-framework-core-mockby cup-of-tea-dot-be
C# 85 Version:Current License: Permissive (MIT)