Programming paths / C# Tutorial / Capstone: Build a Tested .NET Catalog API

C# course contents

Beginner

  1. What C# and .NET Are
  2. Install the .NET SDK and Create a Project
  3. Write Your First C# Program
  4. Types, Variables, and Type Inference
  5. Nullable Reference Types
  6. Strings, Formatting, and Text
  7. Parse and Validate User Input
  8. Operators, Conversions, and Expressions
  9. Branching with if, switch, and Switch Expressions
  10. Loops and Iteration
  11. Methods, Parameters, and Return Values
  12. Arrays, Lists, and Collection Choices
  13. Classes, Objects, and Encapsulation
  14. Properties, Constructors, and Object Invariants
  15. Records and Value-Based Data

Intermediate

  1. Interfaces and Composition
  2. Inheritance, Polymorphism, and Composition Choices
  3. Generics and Generic Constraints
  4. Exceptions and Failure Boundaries
  5. Dictionaries, Sets, and Equality
  6. LINQ Queries and Deferred Execution
  7. Delegates, Lambdas, and Callbacks
  8. Events and Publisher-Subscriber Design
  9. Files, Streams, and Resource Disposal
  10. JSON Serialization and Input Validation
  11. HTTP APIs and HttpClient Lifetime
  12. Asynchronous Programming with Task and async/await
  13. Cancellation Tokens and Responsive Operations
  14. Unit Tests and Testable Code

Advanced

  1. Generic Constraints and Reusable Components
  2. Pattern Matching and Switch Expressions
  3. Modeling Results with Records and Discriminated States
  4. LINQ Performance and Query Boundaries
  5. Dependency Injection and Application Composition
  6. Configuration, Options, and Secrets
  7. Logging, Diagnostics, and Observability
  8. IDisposable, IAsyncDisposable, and Resource Ownership
  9. IAsyncEnumerable and Streaming Results
  10. Span<T>, Memory<T>, and Efficient Data Processing
  11. Tasks, Locks, and Thread-Safe State
  12. Secure C#: Validation, Secrets, and Safe APIs
  13. Profiling, Allocations, and Performance
  14. Attributes, Reflection, and Runtime Metadata
  15. Interop and Native Boundaries

Expert

  1. Designing Stable C# APIs
  2. Application Architecture and Boundaries
  3. Build, Publish, and Deploy .NET Applications
  4. Capstone: Build a Tested .NET Catalog API

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.