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

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Senior Testing Topics

Testing legacy code, async and time-dependent code, distributed systems, flaky test handling, contract testing between services and test data management.

  1. How would you replace the clock in an ASP.NET Core integration test so retries, cache expiry and your own rules all use the same fake time?
    Mid-Level Coding Senior Testing Topics
  2. How would you test that a worker never processes more than four messages at the same time?
    Mid-Level Coding Senior Testing Topics
  3. A tester needs production-like data in UAT to reproduce a bug a customer reported. What do you do?
    Mid-Level Theory Senior Testing Topics
  4. How do you know your characterisation tests are good enough to start changing the code?
    Senior Theory Senior Testing Topics
  5. How do you write a contract for an asynchronous message, such as an OrderPlaced event on Azure Service Bus?
    Senior Coding Senior Testing Topics
  6. How would you test that a message consumer is idempotent when the broker delivers the same message twice?
    Senior Theory Senior Testing Topics
  7. How do you unit test code that depends on the current time in .NET 10? Explain TimeProvider and FakeTimeProvider, how you test expiry rules, timers and delays deterministically, and the gotchas when a timer continuation runs on another thread.

    Testing time-dependent .NET code with the TimeProvider abstraction and FakeTimeProvider: injecting the clock, advancing virtual time, testing PeriodicTimer and Task.Delay, and avoiding races with asynchronous continuations.

    Mid-Level Coding Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  8. How do you write reliable tests for asynchronous .NET code? Explain awaiting correctly instead of blocking, testing cancellation and timeouts, testing a Channel-based BackgroundService, and the xUnit features and analysers that help.

    Testing async .NET code: async test methods, avoiding .Result and async void, asserting cancellation with ThrowsAnyAsync, timeouts with TestContext.Current.CancellationToken, and testing Channel-driven BackgroundService workers deterministically.

    Mid-Level Coding Senior Testing Topics Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. How do you manage test data for a .NET system that handles personal information? Compare test data builders, seeding, masked production copies and synthetic data, and explain how the Privacy Act shapes what you are allowed to use.

    Test data strategy for systems with personal information: object mothers and test data builders, Bogus with fixed seeds, per-test seeding and reset, masked production copies versus synthetic data, and Australian Privacy Act and Notifiable Data Breaches implications.

    Mid-Level Theory Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. You inherit a ten-year-old .NET codebase with almost no tests, and you need to change a core billing calculation safely. How do you get it under test? Explain characterisation tests, seams, and the dependency-breaking techniques you would use first.

    Testing legacy .NET code: characterisation (golden master) tests, Michael Feathers' seams, sprout and wrap methods, extract-interface and parameterise-constructor refactorings, snapshotting outputs with Verify, and choosing safe first refactorings.

    Senior Theory Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. Your CI pipeline fails about one run in ten with different tests each time, and they all pass locally. Developers have started clicking re-run. How do you diagnose the flaky tests, decide what to quarantine, and fix the root causes?

    Debugging flaky .NET tests: reproducing with repeat runs and constrained resources, classifying causes (time, ordering, shared state, parallelism, async races, external dependencies), xUnit collections and parallelism, blame-hang diagnostics, quarantine policy and permanent fixes.

    Senior Debugging Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  12. How would you set up consumer-driven contract testing between two .NET services with Pact? Show a consumer test and provider verification, explain provider states, and how a Pact Broker and can-i-deploy fit into CI.

    Consumer-driven contract testing in .NET with PactNet: writing consumer tests against the Pact mock server with matchers, verifying the provider against a real host with provider states, and using a Pact Broker, pending pacts and can-i-deploy to gate deployments.

    Senior Coding Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  13. How do you test a distributed .NET system made of several services, queues and databases? What can you test locally and in CI, what can only be tested in production, and how would you run chaos experiments safely?

    Testing distributed .NET systems: component tests with real dependencies in containers, .NET Aspire integration tests, contract tests, asserting eventual consistency, fault injection with Polly chaos strategies and Azure Chaos Studio, and testing in production with synthetic monitoring, canaries and feature flags.

    Senior Theory Senior Testing Topics Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me