TE

C# Testing

C# testing conventions

C#
Testing
Default

Details

Language / Topic
csharpC#
Category
Testing

Rules

balanced
- Follow the naming convention: `MethodName_Scenario_ExpectedBehavior`.
- Use the Arrange-Act-Assert pattern. One assertion concept per test method.
- Use the `[Fact]` attribute for single tests and `[Theory]` with `[InlineData]` for parameterized tests in xUnit.
- Use shared fixtures for expensive setup (database, HTTP client) across tests in a class.
- Mock interfaces for dependency isolation — prefer mocking libraries with clean, fluent syntax.
- Use parameterized tests for data-driven scenarios with multiple input combinations.
- Use `Verify()` on mocks to assert that expected interactions occurred.