CURRICULUM PREVIEWRevision 1 · Open for reviewReview the full course
CONNECTING THE PIECES8 min read

A useful testing portfolio

Choose tests by the failure they can reveal.

Before you begintransactions

The idea

Unit tests isolate booking rules. Integration tests verify SQL, migrations, and dependency wiring. HTTP tests verify routes, authorization, and response contracts. A fake repository cannot prove PostgreSQL constraints work, and a large browser suite is a slow place to discover a small rule error.

Follow the flow

Make it concrete

This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.

Focused example
C#
[Theory]
[InlineData(0)]
[InlineData(-1)]
public void RejectsInvalidSeatCount(int seats)
{
    Assert.Throws<ArgumentOutOfRangeException>(
        () => Booking.Create("tenant-a", seats));
}

Decisions that matter

  • Use deterministic inputs and explicit time providers where time affects behavior.
  • Test externally visible behavior rather than private implementation details.
  • A small set of real boundary tests protects the assumptions fakes cannot model.

Your turn

Create a test plan for a tenant-scoped booking lookup with a PostgreSQL adapter.

Reveal a worked answer

Unit-test rule and error mapping. Integration-test the tenant predicate and missing row with PostgreSQL. HTTP-test anonymous access, a caller from another tenant, a valid caller, malformed IDs, and the successful response contract.

Keep exploring

One more piece connected.

Mark this lesson complete when you can explain the idea.