# devlooped/moq

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/devlooped-moq).**

6,389 stars · 834 forks · C# · NOASSERTION

## Links

- GitHub: https://github.com/devlooped/moq
- awesome-repositories: https://awesome-repositories.com/repository/devlooped-moq.md

## Description

Moq is a .NET mocking framework and C# library used to create simulated objects and interfaces. Its primary purpose is to isolate code from external dependencies during unit testing by providing a system for interface simulation and behavioral testing.

The framework distinguishes itself through the use of functional specification queries and LINQ-based querying to create declarative mocks. It supports the simulation of complex scenarios, including the automatic generation of recursive mock hierarchies, the implementation of multiple interfaces within a single mock instance, and the ability to mock protected virtual members.

The library covers broad capability areas including behavioral verification to confirm method invocation frequency and call sequences, and method behavior configuration for defining return values, exceptions, and parameter modifiers. It also provides tools for event simulation and the control of mock strictness to determine how unconfigured members respond.

## Tags

### Programming Languages & Runtimes

- [.NET Testing Ecosystem](https://awesome-repositories.com/f/programming-languages-runtimes/net-testing-ecosystem.md) — Provides a comprehensive mocking framework for isolating dependencies within the .NET runtime environment.
- [Return Value Configurations](https://awesome-repositories.com/f/programming-languages-runtimes/block-value-returns/method-return-values/return-value-interceptors/return-value-configurations.md) — Provides capabilities to define return values and exceptions for simulated methods, including support for asynchronous tasks. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Expression-Based Mock Setup](https://awesome-repositories.com/f/programming-languages-runtimes/language-integrated-query-linq/expression-based-mock-setup.md) — Uses functional expressions and LINQ to declaratively find or create simulated objects with specific behaviors. ([source](https://github.com/devlooped/moq#readme))
- [Multiple Interface Implementations](https://awesome-repositories.com/f/programming-languages-runtimes/class-system-implementations/multiple-interface-implementations.md) — Enables a single mock instance to implement and provide behavior for several different interfaces simultaneously. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Setup Expression Trees](https://awesome-repositories.com/f/programming-languages-runtimes/expression-tree-compilation/setup-expression-trees.md) — Uses expression trees to extract method signatures and argument constraints for behavioral setup.
- [Multi-Interface Mock Generators](https://awesome-repositories.com/f/programming-languages-runtimes/go-mocking-libraries/interface-mock-generators/multi-interface-mock-generators.md) — Generates mock implementations of multiple interfaces with customizable return values and exceptions.
- [Argument Constraint Matchers](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/function-utilities/argument-collectors/splat-argument-validations/argument-constraint-matchers.md) — Evaluates method arguments against constants or custom predicates to trigger specific simulated behaviors.
- [Mock Argument Matchers](https://awesome-repositories.com/f/programming-languages-runtimes/programming-utilities/function-utilities/argument-collectors/splat-argument-validations/argument-constraint-matchers/mock-argument-matchers.md) — Filters method calls using constants, regular expressions, or custom predicates to trigger specific setups. ([source](https://github.com/devlooped/moq/wiki/Quickstart))

### Testing & Quality Assurance

- [Dynamic Mock Objects](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/dynamic-mock-objects.md) — Generates runtime proxy objects to simulate interfaces and classes, isolating the system from external dependencies. ([source](https://github.com/devlooped/moq#readme))
- [Behavior Verification](https://awesome-repositories.com/f/testing-quality-assurance/behavior-verification.md) — Validates that specific methods were called with the correct arguments and in the expected order.
- [Behavioral Verification Tools](https://awesome-repositories.com/f/testing-quality-assurance/behavioral-verification-tools.md) — Verifies that specific method invocations and event triggers occur in a precise, predefined order.
- [C# Mocking Libraries](https://awesome-repositories.com/f/testing-quality-assurance/c-mocking-libraries.md) — Provides a comprehensive toolset for defining method behaviors and call expectations within C# test suites.
- [Method Invocation Verifications](https://awesome-repositories.com/f/testing-quality-assurance/method-invocation-verifications.md) — Confirms that specific methods were called a certain number of times or not at all. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Dependency Mocking](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking.md) — Simulates external system behavior by substituting real components with controlled mock implementations.
- [Mock Call Order Verifications](https://awesome-repositories.com/f/testing-quality-assurance/api-expectation-frameworks/interaction-expectations/ordered/mock-call-order-verifications.md) — Verifies that mock method invocations occur in a predefined sequence across one or more mock objects. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Event-Driven Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/automation-interaction-tools/test-automation-tools/event-driven-testing-frameworks.md) — Simulates asynchronous event triggers and custom data payloads to verify event-based logic.
- [Call-Stack Interceptors](https://awesome-repositories.com/f/testing-quality-assurance/call-stack-interceptors.md) — Captures method invocations and arguments to verify call counts and sequence order against predefined expectations.
- [Declarative Mock Specifications](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/dynamic-mock-objects/declarative-mock-specifications.md) — Supports building stubbed objects and hierarchies using functional specification queries instead of manual setup. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Recursive Mock Generation](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/dependency-mocking/automated-mock-generation/dynamic-mock-objects/recursive-mock-generation.md) — Automatically instantiates new mock objects when a member return value is another mockable type.
- [Protected Method Mocks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/mocking-frameworks/protected-method-mocks.md) — Enables defining behaviors and expectations for protected virtual members using identifiers or proxies. ([source](https://github.com/devlooped/moq/wiki/Quickstart))

### Web Development

- [Mock Proxy Generation](https://awesome-repositories.com/f/web-development/dynamic-proxies/mock-proxy-generation.md) — Creates simulated object implementations at runtime by generating a proxy class that intercepts calls to virtual members.

### Data & Databases

- [Accessor Stubbing](https://awesome-repositories.com/f/data-databases/object-property-accessors/accessor-stubbing.md) — Provides control over property getter return values and verification of setter invocations. ([source](https://github.com/devlooped/moq/wiki/Quickstart))

### Software Engineering & Architecture

- [Mock Default Behavior Configurations](https://awesome-repositories.com/f/software-engineering-architecture/default-configuration-values/mock-default-behavior-configurations.md) — Allows configuring fallback responses or exceptions for unexpected method calls to enforce strict behavior. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Mock Event Triggering](https://awesome-repositories.com/f/software-engineering-architecture/event-buses/event-bus-mocks/mock-event-triggering.md) — Allows manually or automatically firing events on a mock object to simulate notifications. ([source](https://github.com/devlooped/moq/wiki/Quickstart))
- [Method Argument & Return Manipulation](https://awesome-repositories.com/f/software-engineering-architecture/method-interception-proxies/method-argument-return-manipulation.md) — Executes custom logic before or after a mocked method returns to capture arguments or modify state. ([source](https://github.com/devlooped/moq/wiki/Quickstart))

### Part of an Awesome List

- [Testing Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/testing-frameworks.md) — Popular library for mocking interfaces and classes in tests.
