Moq is a lightweight mocking framework for .NET that simplifies creating and managing mock objects in unit tests. It uses expression-based setups for expectations, supports behavior verification, and helps create isolated, deterministic tests by controlling dependencies and integrating easily with common .NET test runners.
Use this profile to understand the building block briefly, place it in the model, and open related building blocks.
Technical building block: can be automated, integrated, or operated.
Concrete cog in the system that works inside larger relationships.
Moq is a .NET library that lets tests replace dependencies with configurable mock objects.
Moq emerged as an open-source project in the .NET ecosystem from the practice of isolating dependencies with test doubles in unit tests. It developed into a library that dynamically simulates interfaces and classes and is used in .NET projects through NuGet.
A test creates a mock for an interface or class and specifies allowed calls and return values. After the Act step it checks state or verifies interactions. This isolates the unit while also making the test's collaboration assumptions explicit.
A mock simulates a dependency and can record expected interactions.
Setups define return values or exceptions for particular calls.
Verification checks whether expected interactions actually occurred.
Moq helps unit tests isolate external dependencies. Excessive verification couples tests to implementation details; integration and contract tests remain necessary to check real collaboration.
Where this building block is located in the topic model.
No structure path available.
Explore how this building block connects to concepts, methods, technologies, and tools.
These sources establish the term and its professional meaning.
All direct connections of the current building block in a compact text view.
This classification shows where the building block typically matters, how demanding it is, and what kind of impact it has in the model.
The level within the organization (enterprise, domain, team) at which the AssetBlock is applied.