Test your Moq knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/5Score 0
What is a reasonable comparison between Moq and NSubstitute, another popular .NET mocking library?
Questions in this quiz
What is a reasonable comparison between Moq and NSubstitute, another popular .NET mocking library?
What is `MockBehavior.Strict` versus the default `MockBehavior.Loose` in Moq?
What is the difference between `Times.Once`, `Times.Never`, and `Times.AtLeastOnce` when used with `.Verify()`?
What does mocking a dependency's interface (rather than testing against the real concrete implementation) allow a unit test to achieve?
How would you configure a Moq mock to throw an exception when a specific method is called, to test error-handling logic?
What is the basic syntax for creating a mock of an interface with Moq?
What is Moq?
Why does Moq require the mocked type to be an interface, an abstract class, or a class with virtual members -- rather than being able to mock any arbitrary sealed class?
What is the purpose of setting up a mocked property (rather than a method) with Moq, e.g. `mockConfig.Setup(c => c.IsEnabled).Returns(true);`?
How does Moq handle mocking async methods (returning `Task<T>`)?
What is a `MockRepository` in Moq, and when would a test use one instead of creating individual `Mock<T>` instances directly?
What is the purpose of `.Callback()` in a Moq setup?