Test your NSubstitute knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/5Score 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?
Questions in this quiz
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?
What does `DidNotReceive()` let a test verify in NSubstitute?
What is the purpose of `Received(n)` (with a specific call count argument) in NSubstitute, as opposed to plain `Received()`?
What is the basic syntax for creating a substitute of an interface with NSubstitute?
What does the term "substitute" specifically emphasize about NSubstitute's naming/design philosophy, compared to the more common industry term "mock"?
What is the purpose of `.Returns()` accepting a callback function (rather than a static value) in NSubstitute, e.g. `repo.GetUserById(Arg.Any<int>()).Returns(x => new User { Id = x.Arg<int>() });`?
How would you configure an NSubstitute substitute to throw an exception when a method is called, to test error-handling logic?
How do you verify that a specific method was called on an NSubstitute substitute?
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?
What is `Arg.Any<T>()` used for in NSubstitute?
What is `Arg.Is<T>()` used for as a more specific alternative to `Arg.Any<T>()` in NSubstitute?
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?