This guide covers coding standards, testing conventions, and the contribution workflow for the TestClone project.
net10.0 for 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 |
using directives.{ of a control-flow block (if, for, foreach, using, try, etc.).return statement on its own line.if/else chains.nameof(...) instead of string literals when referring to member names..editorconfig — the CI pipeline enforces these.Nullable enabled; declare variables as non-nullable unless intentionally nullable.null at public entry points.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);
Directory.Build.props): all compiler warnings must be resolved before merging.Program.cs.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!");
}
_ in test method names.Assert.That(...) assertions.# All tests
dotnet test
# Single test project
dotnet test src/WebApi.UnitTests
dotnet test src/DomainApi.UnitTests
src/DomainModel/Requests/ and src/DomainModel/Responses/.IFacade and implement it in Facade.TestCloneController (or a new controller if the domain warrants it).IFacade) and the Facade implementation.main.dotnet build produces zero warnings.dotnet test passes with all tests green..github/pull_request_template.md).# 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