csharp-testing

Apply xUnit, FluentAssertions, and mocking patterns to C# tests.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Maelwalser/claude-config --skill csharp-testing-maelwalser
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-testing
Source: https://github.com/Maelwalser/claude-config/tree/main/skills/csharp-testing
Command: npx skills add https://github.com/Maelwalser/claude-config --skill csharp-testing-maelwalser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams write reliable, maintainable, and well-structured tests for C# and .NET projects to reduce regressions, flaky tests, and unclear assertions. It consolidates best practices for unit, integration, and API tests so developers can quickly apply consistent patterns across services and libraries.

Core Features & Use Cases

  • Establishes an Arrange-Act-Assert mindset with examples for clear test structure and single-responsibility tests.
  • Demonstrates readable assertions using FluentAssertions and parameterized tests with xUnit Theories.
  • Guides dependency mocking strategies with NSubstitute or Moq and explains verification of interactions.
  • Shows integration test setups using WebApplicationFactory for ASP.NET Core and Testcontainers or in-memory databases for repository tests.
  • Recommends test data builders, fixtures, and project organization to keep tests deterministic and fast.
  • Use Case: Convert brittle repository and API tests into deterministic integration suites using Testcontainers and structured test data builders.

Quick Start

Create or improve xUnit tests for a C# service by applying Arrange-Act-Assert, FluentAssertions for readable checks, and NSubstitute or Moq for dependency isolation.

Frequently Asked Questions about csharp-testing

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

FAQPage Schema
How do I write reliable C# integration tests for ASP.NET Core APIs?

Reliable C# integration tests use WebApplicationFactory to host the API in-memory and Testcontainers to provision real databases, ensuring deterministic end-to-end execution without flaky external dependencies.

What's the best way to structure xUnit tests using FluentAssertions?

The best way to structure xUnit tests is applying the Arrange-Act-Assert pattern for clear separation, using FluentAssertions for readable syntax, and parameterized Theories to execute multiple test cases deterministically.

How do I mock dependencies in dotnet unit tests using NSubstitute or Moq?

Mocking dependencies in dotnet unit tests involves configuring NSubstitute or Moq to isolate the system under test, returning deterministic data while verifying specific interaction behaviors occurred during execution.

Why are my C# repository tests flaky and how do I fix them?

Flaky C# repository tests often stem from shared mutable state or external databases; fixing them requires using in-memory databases or Testcontainers to provision isolated, deterministic database instances per test run.

Do I need Testcontainers for dotnet integration testing or are in-memory databases enough?

Testcontainers are needed for dotnet integration testing when validating actual database behavior, whereas in-memory databases suffice for simpler repository tests but may not catch provider-specific SQL translation issues.

How do I organize test data builders and fixtures in C# testing projects?

Organizing test data builders and fixtures in C# testing projects involves encapsulating complex object construction within builder classes and sharing contextual setups via xUnit fixtures to keep tests fast and maintainable.