
Csharp Testing
This covers the practical side of testing .NET applications with xUnit, FluentAssertions, and NSubstitute or Moq. You get patterns for unit tests with proper AAA structure, parameterized tests with Theory attributes, integration testing using WebApplicationFactory, and Testcontainers for real database tests against Postgres. The examples show actual code for mocking repositories, building test data with the builder pattern, and organizing test projects by layer. It skips the philosophy and gives you copy-pasteable setups for the common scenarios like API endpoint testing and repository integration tests. The anti-patterns table at the end is incomplete in the source but the rest is solid reference material when you need to set up or review test infrastructure.
- skills.sh installs
- 5.5K
- GitHub stars
- 300.3K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add affaan-m/ecc --skill csharp-testing --agent claude-codeInstalls into .claude/skills of the current project.
Files
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
public sealed class OrderServiceTests
{
private readonly IOrderRepository _repository = Substitute.For<IOrderRepository>();
private readonly ILogger<OrderService> _logger = Substitute.For<ILogger<OrderService>>();
private readonly OrderService _sut;
public OrderServiceTests()
{
_sut = new OrderService(_repository, _logger);
}
Sponsors
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Testing & QA, .NET & C#
- First seen
- Jul 14, 2026
More from affaan-m/ecc
All 263- Skill Scout5.5K
- Customs Trade Compliance5.5K
- Research Ops5.5K
- Crosspost5.5K
- Videodb5.5K
- Click Path Audit5.5K
- Skill Comply5.5K
- Hipaa Compliance5.5K
- Angular Developer5.5K
- Regex Vs Llm Structured Text5.5K
- Investor Outreach5.5K
- Homelab Wireguard Vpn5.5K
- Repo Scan5.5K
- Agent Payment X4025.5K
- Ck5.5K
- Clickhouse Io5.5K
- Terminal Ops5.4K
- Knowledge Ops5.4K
- Nutrient Document Processing5.4K
- Kotlin Exposed Patterns5.4K
- Claude Devfleet5.4K
- Finance Billing Ops5.4K
- Healthcare Cdss Patterns5.4K
- Ui To Vue5.4K