Skip to content
Back to skills

Mocking Inprocess Dotnet

ASecurity

Use when the mocking-strategy-roster resolved (inprocess, .NET) — the override mocking strategy that replaces a downstream dependency with an in-process test double (FakeItEasy, NSubstitute, or Moq) instead of a Microcks container. Provides the concrete double registration swapped into the WebApplicationFactory DI. Emits mock wiring only; the business TDD cycle stays with the software-engineer lead.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 26, 2026
ai-agentsapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned September 26, 2026

npx -y skills add SebastienDegodez/skraft-plugin --skill mocking-inprocess-dotnet --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mocking Inprocess Dotnet?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mocking Inprocess Dotnet
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sebastiendegodez-mocking-inprocess-dotnet/badge)](https://www.skillsdirectory.com/skills/sebastiendegodez-mocking-inprocess-dotnet)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mocking-inprocess-dotnet
description: Use when the mocking-strategy-roster resolved (inprocess, .NET) — the override mocking strategy that replaces a downstream dependency with an in-process test double (FakeItEasy, NSubstitute, or Moq) instead of a Microcks container. Provides the concrete double registration swapped into the WebApplicationFactory DI. Emits mock wiring only; the business TDD cycle stays with the software-engineer lead.
---

# Mocking — In-process x .NET adapter (override)

Concrete recipe that mocks a downstream dependency the SUT calls, using an
in-process test double registered in the `WebApplicationFactory` DI, instead of
a Microcks container. Selected when the operator overrides the Microcks default.

Loaded ONLY when `mocking-strategy-roster` resolved `(inprocess, .NET)`. The
roster also passes the chosen library: `fakeiteasy | nsubstitute | moq`. When no
specific library is named, the **Library table below is ordered by priority**
(top = highest): pick the first row whose package is already present in the test
project; if none is present, take the top row.

**Boundary:** mock wiring + integration-test scaffold only. No business TDD, no
Object Calisthenics enforcement, no provider contract verification. The
`software-engineer` lead integrates this into its own TDD loop.

## Library packages (table order = priority, top = highest)

| Priority | Library | NuGet | Double creation |
|---|---|---|---|
| 1 | fakeiteasy | `FakeItEasy` | `A.Fake<I{Downstream}Client>()` |
| 2 | nsubstitute | `NSubstitute` | `Substitute.For<I{Downstream}Client>()` |
| 3 | moq | `Moq` | `new Mock<I{Downstream}Client>()` (use `.Object` for the instance) |

## Recipe — register an in-process double in the test host

```csharp
public class {Sut}ApiFactory : WebApplicationFactory<Program>
{
    public I{Downstream}Client DownstreamDouble { get; } =
        // Create via the resolved library's "Double creation" column above.
        CreateDouble();

    protected override void ConfigureWebHost(IWebHostBuilder builder)
    {
        builder.ConfigureServices(services =>
        {
            // Replace the real downstream client registration with the double.
            services.RemoveAll<I{Downstream}Client>();
            services.AddSingleton(DownstreamDouble);
        });
    }
}
```

The test arranges behaviour on `DownstreamDouble` using the resolved library's
API (`Mock.Setup` / `A.CallTo` / `client.Method(...).Returns(...)`).

## Structured result back to the lead

Return, do not commit:

```yaml
strategy: inprocess
stack: dotnet
library: fakeiteasy | nsubstitute | moq
files:
  - test/{Sut}.IntegrationTests/{Sut}ApiFactory.cs
testCommand: <resolved via resolving-stack-commands>
notes: in-process double for I{Downstream}Client swapped into the test host DI
```

## Rules

- Double the DOWNSTREAM client interface, never the SUT's own domain.
- This is an INTEGRATION-test double at the HTTP boundary — not a Domain/Application
  unit mock (those remain forbidden in the core per craft-discipline).
- Use `resolving-stack-commands` for the test command — never hardcode `dotnet test`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.