All quizzes
Free quiz · 20 questions in the bank

NSubstitute quiz

Test your NSubstitute knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

How would a test using NSubstitute typically verify that a method was called with an argument matching a specific object's properties, without needing that argument to be the EXACT same object reference?

In this round
  1. How would a test using NSubstitute typically verify that a method was called with an argument matching a specific object's properties, without needing that argument to be the EXACT same object reference?
  2. What is `Arg.Is<T>()` used for as a more specific alternative to `Arg.Any<T>()` in NSubstitute?
  3. What is the significance of NSubstitute (like other .NET mocking libraries) being commonly paired with dependency injection as a design pattern in the code under test?
  4. What is the basic syntax for creating a substitute of an interface with NSubstitute?
  5. What is the significance of NSubstitute requiring the mocked member to be an interface member, or a virtual/abstract class member -- similar to the constraint other .NET mocking libraries like Moq share?
  6. How does NSubstitute handle mocking async methods (returning `Task<T>`)?
  7. What is a reasonable justification for a test explicitly using `DidNotReceive()` to verify a negative outcome, rather than simply not writing any verification for that interaction at all?
  8. What is the purpose of `Received(n)` (with a specific call count argument) in NSubstitute, as opposed to plain `Received()`?
  9. How do you configure a substitute's method to return a specific value in NSubstitute?
  10. What is a reasonable strategy for choosing which mocking library (NSubstitute vs. Moq) a .NET team should adopt for a new project?
  11. What is `Arg.Any<T>()` used for in NSubstitute?
  12. What is NSubstitute?
Gaps to close?
Read the curated NSubstitute notes — core concepts, patterns, interview prep.
NSubstitute notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web