{"slug":"mocking-inprocess-dotnet","title":"mocking-inprocess-dotnet","summary":"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 swappe","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-29T00:42:31.294697Z","repo":{"url":"https://github.com/SebastienDegodez/skraft-plugin","stars":17,"forks":3,"license":"GPL-3.0","updatedAt":"2026-11-29T00:18:21Z"},"bodyHtml":"<hr>\n<h2>name: mocking-inprocess-dotnet\ndescription: 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.</h2>\n<h1>Mocking — In-process x .NET adapter (override)</h1>\n<p>Concrete recipe that mocks a downstream dependency the SUT calls, using an\nin-process test double registered in the <code>WebApplicationFactory</code> DI, instead of\na Microcks container. Selected when the operator overrides the Microcks default.</p>\n<p>Loaded ONLY when <code>mocking-strategy-roster</code> resolved <code>(inprocess, .NET)</code>. The\nroster also passes the chosen library: <code>fakeiteasy | nsubstitute | moq</code>. When no\nspecific library is named, the <strong>Library table below is ordered by priority</strong>\n(top = highest): pick the first row whose package is already present in the test\nproject; if none is present, take the top row.</p>\n<p><strong>Boundary:</strong> mock wiring + integration-test scaffold only. No business TDD, no\nObject Calisthenics enforcement, no provider contract verification. The\n<code>software-engineer</code> lead integrates this into its own TDD loop.</p>\n<h2>Library packages (table order = priority, top = highest)</h2>\n<table>\n<thead>\n<tr>\n<th>Priority</th>\n<th>Library</th>\n<th>NuGet</th>\n<th>Double creation</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1</td>\n<td>fakeiteasy</td>\n<td><code>FakeItEasy</code></td>\n<td><code>A.Fake&lt;I{Downstream}Client&gt;()</code></td>\n</tr>\n<tr>\n<td>2</td>\n<td>nsubstitute</td>\n<td><code>NSubstitute</code></td>\n<td><code>Substitute.For&lt;I{Downstream}Client&gt;()</code></td>\n</tr>\n<tr>\n<td>3</td>\n<td>moq</td>\n<td><code>Moq</code></td>\n<td><code>new Mock&lt;I{Downstream}Client&gt;()</code> (use <code>.Object</code> for the instance)</td>\n</tr>\n</tbody>\n</table>\n<h2>Recipe — register an in-process double in the test host</h2>\n<pre><code>public class {Sut}ApiFactory : WebApplicationFactory&lt;Program&gt;\n{\n    public I{Downstream}Client DownstreamDouble { get; } =\n        // Create via the resolved library's \"Double creation\" column above.\n        CreateDouble();\n\n    protected override void ConfigureWebHost(IWebHostBuilder builder)\n    {\n        builder.ConfigureServices(services =&gt;\n        {\n            // Replace the real downstream client registration with the double.\n            services.RemoveAll&lt;I{Downstream}Client&gt;();\n            services.AddSingleton(DownstreamDouble);\n        });\n    }\n}\n</code></pre>\n<p>The test arranges behaviour on <code>DownstreamDouble</code> using the resolved library's\nAPI (<code>Mock.Setup</code> / <code>A.CallTo</code> / <code>client.Method(...).Returns(...)</code>).</p>\n<h2>Structured result back to the lead</h2>\n<p>Return, do not commit:</p>\n<pre><code>strategy: inprocess\nstack: dotnet\nlibrary: fakeiteasy | nsubstitute | moq\nfiles:\n  - test/{Sut}.IntegrationTests/{Sut}ApiFactory.cs\ntestCommand: &lt;resolved via resolving-stack-commands&gt;\nnotes: in-process double for I{Downstream}Client swapped into the test host DI\n</code></pre>\n<h2>Rules</h2>\n<ul>\n<li>Double the DOWNSTREAM client interface, never the SUT's own domain.</li>\n<li>This is an INTEGRATION-test double at the HTTP boundary — not a Domain/Application\nunit mock (those remain forbidden in the core per craft-discipline).</li>\n<li>Use <code>resolving-stack-commands</code> for the test command — never hardcode <code>dotnet test</code>.</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":3150,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-29T00:44:06.277313Z","sha256":"DF9B1AF8A83C58AA808D38CE4CA10377301BA68912BDA13812A9D50C9B35B0F9","sizeBytes":1555},"review":null,"source":{"repositoryUrl":"https://github.com/SebastienDegodez/skraft-plugin","path":"plugins/skraft-framework/skills/mocking-inprocess-dotnet","license":"GPL-3.0","commit":"c6117c6236a25490bf1916b131866069740c9b22","subtreeSha":"24CD00BE74C74DB5BE62C2CB627AA883D15A4C1BA47D076EB61A6D43B14B5674","lastSyncedAt":"2026-11-29T00:42:27.348488Z"},"reviewedAt":"2026-11-29T00:47:35.694518Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/SebastienDegodez/skraft-plugin/tree/main/plugins/skraft-framework/skills/mocking-inprocess-dotnet"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install sebastiendegodez-skraft-plugin@llmmart"},{"target":"git","command":"git clone https://github.com/SebastienDegodez/skraft-plugin.git"}]}