# csharp-test > 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". - Author: Zada Zorg - Repository: zadazorg/csharp-standards - Version: 20260124224759 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/zadazorg/csharp-standards - Web: https://mule.run/skillshub/@@zadazorg/csharp-standards~csharp-test:20260124224759 --- --- 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 1. **NO logic in tests** — zero `if`, `for`, `while` 2. **ONE act per test** — single method call 3. **NO `Thread.Sleep`** — use `TimeProvider` 4. **NO mocking records/structs** — use real instances 5. **FluentAssertions FORBIDDEN** — use Shouldly ## Test Structure Template ```csharp public sealed class OrderServiceTests { [Fact] public async Task Should_CreateOrder_When_ValidInput() { // Arrange var repository = Substitute.For(); 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`: ```xml <_Parameter1>MyProduct.Tests ``` ## Code Coverage ```bash dotnet test --collect:"XPlat Code Coverage" ``` Required package in test project: ```xml ``` ## References Load detailed documentation as needed: | Topic | File | |-------|------| | Full Testing Guide | [references/testing.md](references/testing.md) |