generate-testability-wrappers

Generate wrapper interfaces and DI registration for untestable static dependencies in C#.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/Netcodr81/kinetic-reports --skill generate-testability-wrappers-netcodr81
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: generate-testability-wrappers
Source: https://github.com/Netcodr81/kinetic-reports/tree/main/.github/skills/generate-testability-wrappers
Command: npx skills add https://github.com/Netcodr81/kinetic-reports --skill generate-testability-wrappers-netcodr81

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Static dependencies like DateTime.Now, File., Environment., and Console.* make C# classes impossible to unit test because they cannot be mocked. This Skill generates the abstraction layer—wrapper interfaces, default implementations, and DI registration—needed to make such code testable. ## Core Features & Use Cases - Built-in abstraction adoption: Guides first-time setup of TimeProvider (.NET 8+ or via Microsoft.Bcl.TimeProvider) and IHttpClientFactory, including FakeTimeProvider test examples. - Custom wrapper generation: Creates minimal IEnvironmentProvider, IConsole, and IProcessRunner interfaces that wrap only the static members actually used in the codebase, plus default implementations and DI registration. - File system abstraction: Recommends and configures the System.IO.Abstractions NuGet package with MockFileSystem testing patterns. - Use Case: After identifying that a legacy OrderProcessor class calls DateTime.UtcNow and File.ReadAllText directly, use this Skill to adopt TimeProvider and IFileSystem, register them in DI, and write tests with FakeTimeProvider and MockFileSystem. ## Quick Start Generate a testability wrapper for the static file system calls in my ConfigLoader class and show me how to register it in DI.

Frequently Asked Questions about generate-testability-wrappers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make static methods testable in C#?▼

Wrap the static calls behind an interface, inject that interface via constructor, and register the default implementation in DI. For time, file system, and HTTP, prefer built-in abstractions like TimeProvider, System.IO.Abstractions, and IHttpClientFactory over custom wrappers.

How do I replace DateTime.Now with an injectable abstraction?▼

On .NET 8+, register TimeProvider.System as a singleton and inject TimeProvider into your classes. For earlier frameworks, install the Microsoft.Bcl.TimeProvider NuGet package, which provides the same API. Test with FakeTimeProvider from Microsoft.Extensions.TimeProvider.Testing.

Should I write a custom file system wrapper or use System.IO.Abstractions?▼

Use the System.IO.Abstractions NuGet package rather than a custom wrapper. It provides a complete IFileSystem interface, and the System.IO.Abstractions.TestingHelpers package offers MockFileSystem for unit tests.

Can I make statics testable without dependency injection?▼

Yes, use the ambient context pattern with AsyncLocal<T> to hold an optional override delegate. AsyncLocal is required because ThreadStatic breaks with async/await, and the override should be scoped via an IDisposable that resets it.

When should I not generate a testability wrapper?▼

Skip wrapper generation when the static is already behind an interface, when you only need to find statics (use detection first), or when you need to migrate existing call sites after the wrapper exists. Also avoid wrapping members never called in the codebase.