-
Notifications
You must be signed in to change notification settings - Fork 0
Development Guide
HarroCReineking edited this page Feb 26, 2026
·
1 revision
This guide covers coding standards, testing conventions, and the contribution workflow for the TestClone project.
- C# 14 — use the latest language features (primary constructors, pattern matching, collection expressions, etc.).
-
.NET 10 / ASP.NET Core 10 — target
net10.0for all projects.
| Construct | Convention | Example |
|---|---|---|
| Types, methods, public members | PascalCase |
CreateOrder, OrderId
|
| Interfaces |
I prefix + PascalCase |
IFacade |
| Private fields | _camelCase |
_facade |
| Local variables, parameters | camelCase | createOrderRequest |
- File-scoped namespace declarations and single-line
usingdirectives. - Insert a blank line before every opening
{of a control-flow block (if,for,foreach,using,try, etc.). - Final
returnstatement on its own line. - Prefer pattern matching and switch expressions over
if/elsechains. - Use
nameof(...)instead of string literals when referring to member names. - Apply formatting rules from
.editorconfig— the CI pipeline enforces these.
- All projects have
Nullableenabled; declare variables as non-nullable unless intentionally nullable. - Check for
nullat public entry points. - Use
is null/is not null— never== null/!= null.
Every public API surface (classes, interfaces, methods, properties) must have an XML <summary> comment. Include <param>, <returns>, and optionally <example> / <code> where appropriate.
/// <summary>
/// Creates a new product order based on the provided request.
/// </summary>
/// <param name="request">The order creation request containing product name and quantity.</param>
/// <returns>A task that returns the created order response with order ID and status.</returns>
Task<CreateOrderResponse> CreateOrder(CreateOrderRequest request);-
Warnings treated as errors (
Directory.Build.props): all compiler warnings must be resolved before merging. - Prefer constructor injection for all dependencies; register services in
Program.cs. - Keep controllers thin — delegate all business logic to
IFacade.
| Library | Purpose |
|---|---|
| TUnit | Unit testing framework |
| Moq | Mocking / test-double creation |
| Project | What it tests |
|---|---|
src/WebApi.UnitTests |
Controllers (mocked IFacade) |
src/DomainApi.UnitTests |
Facade business logic (no mocking needed) |
ClassNameMethodNameExpectedBehavior
Example: TestCloneControllerGetTestOperationReturnsOkWithFacadeResult
Use // Arrange, // Act, // Assert comments to clearly separate the three phases:
[Test]
public async Task TestCloneControllerGetTestOperationReturnsOkWithFacadeResult()
{
// Arrange
var mockFacade = new Mock<IFacade>();
mockFacade.Setup(f => f.TestOperation()).ReturnsAsync("Hello from the Facade!");
var controller = new TestCloneController(mockFacade.Object);
// Act
var result = await controller.GetTestOperation();
// Assert
var okResult = result as OkObjectResult;
await Assert.That(okResult).IsNotNull();
await Assert.That(okResult!.Value).IsEqualTo("Hello from the Facade!");
}- Do not use
_in test method names. - Do not use FluentAssertions — use TUnit's built-in
Assert.That(...)assertions. - Do not add XML documentation comments to test methods.
- Always cover the critical paths of every new feature.
# All tests
dotnet test
# Single test project
dotnet test src/WebApi.UnitTests
dotnet test src/DomainApi.UnitTests-
DomainModel — Add request/response DTOs in
src/DomainModel/Requests/andsrc/DomainModel/Responses/. -
DomainApi — Add the operation signature to
IFacadeand implement it inFacade. -
WebApi — Add a new action method to
TestCloneController(or a new controller if the domain warrants it). -
Tests — Add unit tests for both the controller action (mock
IFacade) and theFacadeimplementation.
- Fork or branch from
main. - Implement your changes following the coding standards above.
- Ensure
dotnet buildproduces zero warnings. - Ensure
dotnet testpasses with all tests green. - Open a Pull Request using the provided PR template (
.github/pull_request_template.md). - Address review feedback and update your branch as needed.
# Build (warnings treated as errors)
dotnet build
# Run the API locally
dotnet run --project src/WebApi
# Run all unit tests
dotnet test
# Restore NuGet packages
dotnet restore- Home — project overview and navigation.
- Getting Started — first-time setup.
- API Reference — available endpoints.
- Architecture Overview — layer responsibilities and design patterns.