Sets up integration tests for ASP.NET Core APIs using WebApplicationFactory and Testcontainers for real database testing. Produces a working test project with sample passing test.
Ships in TheCodeMan .NET AI ToolKit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Stand up real integration tests for an ASP.NET Core API: a custom WebApplicationFactory, a real database via Testcontainers, and a sample test that exercises the full HTTP pipeline.
Point this at the API project or repo, not a pasted file — inspect what exists first:
Program.cs, the endpoints, and any existing integration-test project.git clone --depth 1 <url> /tmp/repo && cd /tmp/repoDiscover the surface yourself before generating, e.g.:
find <target> -name Program.cs | grep -vi "/obj/\|/bin/"
grep -rn "MapGet\|MapPost\|MapPut\|MapDelete\|: ControllerBase\|ICarterModule" --include=*.cs <target> | head
find <target> -iname "*IntegrationTest*" -o -iname "*.IntegrationTests.csproj"
If an integration-test project already exists, review and extend it (e.g. flag EnsureDbCreated vs MigrateAsync, unpinned images, missing state reset) instead of scaffolding from scratch. Pick a representative endpoint to produce the first test.
The user wants tests that exercise the app for real — routing, DI, middleware, EF Core against an actual database — not mocked units. Inspect the project, then confirm the database (default PostgreSQL via Testcontainers; support SQL Server) only if you can't infer it from the existing setup.
dotnet add package Microsoft.AspNetCore.Mvc.Testing
dotnet add package Testcontainers.PostgreSql # or Testcontainers.MsSql
dotnet add package xunit
dotnet add package FluentAssertions
dotnet add package Respawn # reset DB state between tests
public class IntegrationTestFactory : WebApplicationFactory<Program>, IAsyncLifetime
{
private readonly PostgreSqlContainer _db = new PostgreSqlBuilder()
.WithImage("postgres:16-alpine")
.Build();
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureTestServices(services =>
{
// Remove the app's registered DbContext and point it at the container
services.RemoveAll<DbContextOptions<AppDbContext>>();
services.AddDbContext<AppDbContext>(o => o.UseNpgsql(_db.GetConnectionString()));
});
}
public async Task InitializeAsync()
{
await _db.StartAsync();
using var scope = Services.CreateScope();
var ctx = scope.ServiceProvider.GetRequiredService<AppDbContext>();
await ctx.Database.MigrateAsync();
}
public new async Task DisposeAsync() => await _db.DisposeAsync();
}
Programmust be reachable — addpublic partial class Program { }at the bottom of the API'sProgram.csif using top-level statements.
[CollectionDefinition(nameof(IntegrationCollection))]
public class IntegrationCollection : ICollectionFixture<IntegrationTestFactory> { }
[Collection(nameof(IntegrationCollection))]
public class OrdersApiTests
{
private readonly HttpClient _client;
public OrdersApiTests(IntegrationTestFactory factory) => _client = factory.CreateClient();
[Fact]
public async Task CreateOrder_ReturnsCreated_AndPersists()
{
var request = new { customerId = Guid.NewGuid(), lines = new[] { new { sku = "SKU1", qty = 2 } } };
var response = await _client.PostAsJsonAsync("/orders", request);
response.StatusCode.Should().Be(HttpStatusCode.Created);
var id = await response.Content.ReadFromJsonAsync<Guid>();
id.Should().NotBeEmpty();
var getResponse = await _client.GetAsync($"/orders/{id}");
getResponse.StatusCode.Should().Be(HttpStatusCode.OK);
}
}
To keep tests independent without restarting the container, reset tables between tests:
private Respawner _respawner = default!;
// after migrate:
_respawner = await Respawner.CreateAsync(connString,
new RespawnerOptions { DbAdapter = DbAdapter.Postgres });
// in a reset hook:
await _respawner.ResetAsync(connString);
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
.NET, C#, PostgreSQL
49 skills in this plugin
/adonet-data-access-auditorAudit and fix classic ADO.NET data-access code (SqlConnection / SqlCommand / SqlDataReader / DataSet) on .NET Framework. Use this skill whenever the user shares raw ADO.NET code, a DAL / repository built on SqlCommand, stored-proc calls, string-concatenated SQL, or mentions SQL injection, parameterized queries, connection leaks, "using / Dispose", reading the same column multiple times, transactions, or "why does my old data layer leak connections / is it safe". Always use this skill for classic ADO.NET review instead of answering from memory; it applies a fixed security + correctness + performance checklist and rewrites the code./async-await-auditorAudit C#/.NET code for async/await anti-patterns and concurrency bugs. Use this skill whenever the user shares async C# code or asks about deadlocks, async void, .Result/.Wait(), blocking calls, ConfigureAwait, sync-over-async, fire-and-forget tasks, CancellationToken usage, or "why does my async code hang/deadlock". Always use this skill for async correctness/performance reviews instead of answering from memory; it applies a fixed checklist and rewrites the code./authorization-policy-generatorDesign ASP.NET Core authorization — policy-based, role-based, and claims/requirement-based with custom authorization handlers and resource-based checks. Use this skill whenever the user wants authorization policies, role/claim checks, custom AuthorizationHandler, resource-based authorization, permission checks, or asks "how do I authorize this / policy vs role / restrict this endpoint to X". Always use this skill for authorization requests; it generates policies, handlers, and endpoint wiring./benchmarkdotnet-setupSet up BenchmarkDotNet for a .NET project and interpret the results — proper benchmark classes, memory diagnostics, baselines, and reading ns/op + allocations. Use this skill whenever the user wants to benchmark code, measure performance, compare two implementations, set up BenchmarkDotNet, or asks "which is faster / how do I benchmark this / interpret these benchmark results". Always use this skill for micro-benchmarking requests; it writes correct benchmarks and explains the numbers./caching-strategy-setupAdd the right caching to a .NET app — IMemoryCache, distributed cache, or HybridCache (.NET 9+) — with correct keys, expiration, stampede protection, and invalidation. Use this skill whenever the user wants caching, to cache a query/response, IMemoryCache, Redis/distributed cache, HybridCache, output caching, or asks "how do I cache this / add caching / avoid cache stampede". Always use this skill for caching requests; it picks the right layer and wires expiration + invalidation correctly./cicd-pipeline-generatorGenerate a CI/CD pipeline for a .NET app — GitHub Actions or Azure DevOps — with restore, build, test, coverage, vulnerability scan, container build, and deploy stages. Use this skill whenever the user wants a CI/CD pipeline, GitHub Actions workflow, Azure DevOps YAML, build/test automation, a release pipeline, or asks "how do I set up CI / pipeline for .NET / automate build and deploy". Always use this skill for CI/CD requests; it generates a complete, sensible pipeline./dotnet-ai-toolkit:integration-test-setupfrom TheCodeMan .NET AI ToolKit
npx claudepluginhub stefanthecode/dotnet-ai-toolkit --plugin dotnet-ai-toolkitOther plugins' skills for the same job