📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you test that an ASP.NET Core endpoint behaves correctly when a third-party API it calls is slow or returns errors?

Intermediate Theory Intermediate

🎯 Key points

  • WireMock.Net server as the typed HttpClient's base address
  • Simulate 500, 503, 429 with Retry-After, timeouts and slow responses
  • Assert retries via the WireMock.Net request log
  • Assert timeout and circuit breaker behaviour of the resilience pipeline (Microsoft.Extensions.Http.Resilience, AddStandardResilienceHandler, built on Polly v8)
  • Endpoint maps each failure to a sensible ProblemDetails (502/503/504), not a hang or a raw 500
  • Check the failure is logged with the dependency name and correlation ID
  • Keep tests fast by shortening pipeline timeouts in test configuration or using FakeTimeProvider

⏱ 30-second answer

Point the typed HttpClient at a WireMock.Net server in the test and configure it to return 500s, 429s with Retry-After, or delayed responses. Then assert your API's behaviour: the resilience pipeline (AddStandardResilienceHandler) retries the right number of times, the timeout fires, the circuit breaker opens, and the endpoint returns a sensible ProblemDetails (502 or 503) instead of hanging. Use FakeTimeProvider where possible so retries and timeouts don't make the test slow, and check WireMock's request log to count retries.

🔍 What the interviewer is checking

Checks fault injection with WireMock.Net and resilience pipelines.

↩ Usually asked after

More in Test Types

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me