Agent skill · software engineering · affaan-m

csharp-testing

使用 xUnit、FluentAssertions、模拟、集成测试和测试组织最佳实践的 C# 和 .NET 测试模式。

Why this skill is useful

Provides specific testing patterns and practices for C# and .NET applications that the AI wouldn't reliably generate on its own.

What it needs

Requires dotnet installed locally. About 3k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

C# 测试模式 使用 xUnit、FluentAssertions 和现代测试实践为 .NET 应用程序提供的全面测试模式。 何时使用 为 C# 代码编写新测试 审查测试质量和覆盖率 为 .NET 项目搭建测试基础设施 调试不稳定或缓慢的测试 测试框架栈 工具 用途 --- --- xUnit 测试框架(.NET 首选) FluentAssertions 可读的断言语法 NSubstitute 或 Moq 模拟依赖项 Testcontainers 集成测试中的真实基础设施 WebApplicationFactory ASP.NET Core 集成测试 Bogus 生成逼真的测试数据 单元测试结构 安排-操作-断言 使用 Theory 的参数化测试 使用 NSubstitute 进行模拟 ASP.NET Core 集成测试 WebApplicationFactory 设置 使用 Testcontainers 进行测试 测试组织 测试数据构建器 常见反模式 反模式 修复方法 --- --- 测试实现细节 测试行为和结果 共享的可变测试状态 每个测试使用新实例(xUnit 通过构造函数实现) 在异步测试中使用 Thread.Sleep 使用带超时的 Task.Delay 或轮询辅助方法 对 ToString() 输出进行断言 对类型化属性进行断言 每个测试一个巨型断言 每个测试一个逻辑断言 测试名称描述实现 按行为命名:MethodExpectedResultWhenCondition 忽略 CancellationToken 始终传递并验证取消 运行测试

How to use it

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

@skills affaan-m/csharp-testing--4f172f

View the source on GitHub

Browse the @skills marketplace