Use a test pyramid driven by risk. Unit-test pure domain rules, integration-test database mappings and external adapters, and keep a smaller set of end-to-end tests for critical user journeys. Example: [Fact] public void Rejects_negative_quantity() => Assert.Throws<ArgumentOutOfRangeException>(() => new Line(-1, 10m)); For API integration tests, use WebApplicationFactory, a real disposable database matching production, and authenticated test identities. Test success, validation, authorization, tenant isolation, concurrency, cancellation, and dependency failures. Make tests deterministic: control time and IDs, avoid shared mutable fixtures, and assert observable behavior rather than implementation details.
Backbencher Developer · · 0 likes