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.
By affaan-m · 2,850 installs
npx skills add affaan-m/ecc --skill csharp-testing
Source repository · Upstream listing
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: Method ExpectedResult WhenCondition
Ignoring CancellationToken Always pass and verify cancellation
Running Tests