Agent skill · affaan-m

csharp-testing

C# and .NET testing patterns with xUnit, FluentAssertions, mocking, integration tests, and test organization best practices. Use when writing or reviewing xUnit tests, mocks, or integration tests in a C# / .NET project.

What it needs

About 3k tokens when loaded.

What this skill does

C# Testing Patterns Comprehensive testing patterns for .NET applications using xUnit, FluentAssertions, and modern testing practices. When to Activate Writing new tests for C# code Reviewing test quality and coverage Setting up test infrastructure for .NET projects Debugging flaky or slow tests Test Framework Stack Tool Purpose --- --- xUnit Test framework (preferred for .NET) FluentAssertions Readable assertion syntax NSubstitute or Moq Mocking dependencies Testcontainers Real infrastructure in integration tests WebApplicationFactory ASP.NET Core integration tests Bogus Realistic test data generation Unit Test Structure Arrange-Act-Assert Parameterized Tests with Theory Mocking with NSubstitute ASP.NET Core Integration Tests WebApplicationFactory Setup Testing with Testcontainers Test Organization Test Data Builders Common Anti-Patterns Anti-Pattern Fix --- --- Testing implementation details Test behavior and outcomes Shared mutable test state Fresh instance per test (xUnit does this via constructors) Thread.Sleep in async tests Use Task.Delay with timeout, or polling helpers Asserting on ToString() output Assert on typed properties One giant assertion per test One logical assertion per test Test names describing implementation Name by behavior: MethodExpectedResultWhenCondition Ignoring CancellationToken Always pass and verify cancellation Running Tests

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/csharp-testing--147c10

View the source on GitHub

Browse the @skills marketplace