Test your Moq knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.
Question 1/12Score 0
What does `mockRepo.Setup(r => r.GetAllUsers()).Returns(new List<User> { user1, user2 });` demonstrate about controlling collection-returning methods with Moq?
In this round
What does `mockRepo.Setup(r => r.GetAllUsers()).Returns(new List<User> { user1, user2 });` demonstrate about controlling collection-returning methods with Moq?
How would you configure a Moq mock to throw an exception when a specific method is called, to test error-handling logic?
What does mocking a dependency's interface (rather than testing against the real concrete implementation) allow a unit test to achieve?
What does `.Setup()` configure on a Moq mock?
What is Moq?
What is a `MockRepository` in Moq, and when would a test use one instead of creating individual `Mock<T>` instances directly?
What does `.Verify()` let you check on a Moq mock, and why is this useful?
What does chaining multiple `.Setup()` calls for the SAME method but with DIFFERENT specific argument values achieve on a Moq mock?
What is the difference between `Times.Once`, `Times.Never`, and `Times.AtLeastOnce` when used with `.Verify()`?
What is `It.IsAny<T>()` used for within a Moq `.Setup()` or `.Verify()` call?
What is the basic syntax for creating a mock of an interface with Moq?
What is the purpose of `mockRepo.Object` after configuring a Moq mock?