← スキル一覧に戻る

csharp-test
by zadazorg
⭐ 0🍴 0📅 2026年1月26日
SKILL.md
name: csharp-test description: > Testing standards for C# 14 / .NET 10 with xUnit and Shouldly. Covers naming conventions (Should_X_When_Y), AAA pattern, test data builders, and mocking rules. Use for writing tests, "/test", or "help with tests". user-invocable: true allowed-tools:
- Read
- Write
- Edit
- Grep
- Glob metadata: author: csharp-standards version: "4.0.0"
Testing Standards
Write tests that are readable, maintainable, and reliable.
Core Principles
| Principle | Rule |
|---|---|
| Framework | xUnit + Shouldly (NOT FluentAssertions - license!) |
| Naming | Should_[Result]_When_[Condition] |
| Structure | AAA: Arrange → Act → Assert |
| SUT | Name object under test sut |
| Mocking | Mock ONLY I/O (HTTP, DB, Files) |
Quick Rules
- NO logic in tests — zero
if,for,while - ONE act per test — single method call
- NO
Thread.Sleep— useTimeProvider - NO mocking records/structs — use real instances
- FluentAssertions FORBIDDEN — use Shouldly
Test Structure Template
public sealed class OrderServiceTests {
[Fact]
public async Task Should_CreateOrder_When_ValidInput() {
// Arrange
var repository = Substitute.For<IOrderRepository>();
var sut = new OrderService(repository);
var command = new CreateOrderCommand(CustomerId.New(), Money.FromDecimal(99.99m));
// Act
var result = await sut.CreateAsync(command, CancellationToken.None);
// Assert
result.IsError.ShouldBeFalse();
result.Value.Id.ShouldNotBe(OrderId.Empty);
}
}
Testing Internal Types
Add to main project .csproj:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>MyProduct.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
Code Coverage
dotnet test --collect:"XPlat Code Coverage"
Required package in test project:
<PackageReference Include="coverlet.collector" />
References
Load detailed documentation as needed:
| Topic | File |
|---|---|
| Full Testing Guide | references/testing.md |
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です