C# and .NET • Modern C# baseline
Capstone: Build a Tested .NET Catalog API
Combine C# types, async I/O, validation, dependency injection, and tests in a practical service.
Build a small catalog API that accepts validated records, supports search and pagination, and stores data through an injected repository. Keep domain rules separate from HTTP concerns. Add tests for malformed requests, duplicate identifiers, empty results, cancellation, and storage failures.
Key points
- Use records or classes according to the identity and mutability of each entity.
- Validate request data at the boundary and enforce domain invariants in the domain model.
Example
public sealed record CatalogItem(
string Id,
string Name,
DateTimeOffset CreatedAt);
public interface ICatalogRepository
{
Task<CatalogItem?> FindAsync(
string id,
CancellationToken cancellationToken);
}
What to expect
A complete implementation should return a clear not-found result, honor cancellation, and avoid leaking persistence details to API callers.
Practice exercise
Write a test plan before implementation. Cover valid input, invalid fields, duplicate IDs, cancellation, and repository failure.
Key idea: Production-ready C# combines strong types, explicit boundaries, secure defaults, and automated verification.