moq

Community

Mock dependencies in .NET tests with precision.

AuthorStuartF303
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Moq provides type-safe mocking for .NET unit tests, enabling you to isolate the system under test by replacing real collaborators with test doubles. This reduces flakiness and clarifies behavior verification across small and large codebases.

Core Features & Use Cases

  • Type-safe mocking: Create Mock<T> instances to stand in for interfaces and classes under test.
  • Interaction verification: Assert that specific methods were called, with expected arguments and call counts.
  • Async support and callbacks: Use ReturnsAsync, Callback, and It.IsAny to model asynchronous behavior and capture inputs.
  • Real-world scenarios: Test services, controllers, and workflows in Sorcha by isolating dependencies like repositories and external clients.

Quick Start

To begin using Moq, declare mocks in your test class, initialize Mock<T> dependencies in the constructor, and inject their .Object into the System Under Test. Then configure behavior with Setup and verify with Verify. For example:

  • Initialize mocks: public class WalletManagerTests { private readonly Mock<ICryptoModule> _mockCryptoModule; private readonly Mock<IHashProvider> _mockHashProvider; public WalletManagerTests() { _mockCryptoModule = new Mock<ICryptoModule>(); _mockHashProvider = new Mock<IHashProvider>(); } }

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: moq
Download link: https://github.com/StuartF303/Sorcha/archive/main.zip#moq

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.