Test an endpoint through the real ASP.NET Core pipeline with WebApplicationFactory so routing, model binding, filters, authentication, serialization, and persistence participate. Example: var client = factory.CreateClient(); client.DefaultRequestHeaders.Authorization = TestToken.For(user); var response = await client.PostAsJsonAsync("/api/orders", request); Assert.Equal(HttpStatusCode.Created, response.StatusCode); Use an isolated real database compatible with production, reset it between tests, and seed only through supported boundaries where practical. Cover success, invalid input, unauthenticated/forbidden access, duplicate/idempotent calls, concurrency, dependency failure, and RestaurantId/OutletId isolation. Assert response contracts and database state, not private implementation calls.
Backbencher Developer · · 0 likes