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.
xUnit, NUnit, MSTest, Moq, NSubstitute, FakeItEasy, FluentAssertions and its alternatives, AutoFixture, Testcontainers, WebApplicationFactory and WireMock.Net.
Sharing an expensive test resource (such as a SQL Server container) across xUnit test classes with IAsyncLifetime, class, collection and xUnit v3 assembly fixtures, and keeping tests independent with Respawn or unique keys.
The five kinds of test double (dummy, stub, fake, mock, spy), how they differ in state versus interaction verification, and when a hand-rolled fake beats a mocking library in .NET 10 tests.
When snapshot testing with Verify beats explicit assertions, how .verified and .received files, scrubbing and accepting changes work, and how to keep snapshots reviewable and maintainable.
Preventing a NuGet update from silently bringing in a new licence: Central Package Management, pinned majors and lock files, Dependabot ignore rules, CI licence allow-lists (dependency-review-action, nuget-license), and treating test packages like production dependencies.
Wiring a Testcontainers SQL Server into WebApplicationFactory: container lifecycle with IAsyncLifetime, overriding the connection string, migrating once, resetting with Respawn, and sharing one container across classes with a database per class.
Configuring HttpClient resilience in .NET 10 with Microsoft.Extensions.Http.Resilience (the standard handler's strategies and defaults, attempt versus total timeout, no blind retries on unsafe methods, custom Polly pipelines) and testing it deterministically with WireMock.Net.
Managing test data at each level of the test pyramid without production data: builders and object mothers for unit tests, unique data and Respawn resets for integration tests, seeded synthetic data (Bogus) for end-to-end environments, edge cases, versioned seed scripts, and Australian privacy obligations.
A team-level approach to flaky tests in .NET: measuring flakiness from CI test reports, reproducing failures (loops, parallelism, limited CPU, blame options), the common root causes, a visible quarantine with an owner and deadline, and prevention with TimeProvider, banned-API analysers, xUnit analysers and a flaky-rate dashboard.
Compares xUnit, NUnit and MSTest on test-class lifecycle, setup and teardown, shared fixtures, data-driven tests and parallel execution, and covers xUnit v3 and Microsoft.Testing.Platform on .NET 10.
Covers creating substitutes with NSubstitute and Moq, configuring returns, argument matchers, verifying received calls, throwing exceptions, async members, analysers, and the 2023 Moq SponsorLink supply-chain controversy.
Covers the FluentAssertions v8 move to a commercial Xceed licence, the AwesomeAssertions fork, Shouldly, built-in xUnit/NUnit/MSTest asserts, structural equivalence, failure-message quality and how to choose and migrate.
Covers WebApplicationFactory and TestServer: bootstrapping Program, ConfigureTestServices to swap dependencies, a test authentication handler for protected endpoints, per-test configuration, isolation and what in-memory tests do and do not prove.
Covers Testcontainers for .NET modules for SQL Server and Redis, IAsyncLifetime fixtures, sharing containers per class or collection, container reuse, resetting data with Respawn, wait strategies, Ryuk clean-up, and running in GitHub Actions and Azure Pipelines.
Covers WireMock.Net as a real HTTP stub server for outbound calls: request matching, JSON responses, delays, faults and stateful scenarios, wiring the base URL into WebApplicationFactory, verifying requests from the log, and testing resilience pipelines.
Covers AutoFixture (Create, Build/With, AutoData, Frozen, AutoNSubstitute), hand-written test data builders and Object Mothers, Bogus for realistic synthetic data, and the trade-off between anonymous values and readable, intention-revealing tests.
A senior code review of a brittle .NET test suite: tests that cannot fail, shared static state, Thread.Sleep waits, real clock usage, over-mocking and log-text assertions, ranked by severity, with a rewrite using FakeTimeProvider, FakeLogger, real infrastructure and deterministic waits.