All quizzes
Free quiz · 20 questions in the bank

Moq quiz

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 the purpose of `.Callback()` in a Moq setup?

Questions in this quiz
  1. What is the purpose of `.Callback()` in a Moq setup?
  2. What is a common reason a team chooses to mock a dependency in a unit test rather than using the real implementation?
  3. Why must a class member be declared as `virtual` (for a class, as opposed to an interface) in order for Moq to mock it?
  4. What does chaining multiple `.Setup()` calls for the SAME method but with DIFFERENT specific argument values achieve on a Moq mock?
  5. What is `MockBehavior.Strict` versus the default `MockBehavior.Loose` in Moq?
  6. What is the purpose of `mockRepo.Object` after configuring a Moq mock?
  7. What is Moq?
  8. What does mocking a dependency's interface (rather than testing against the real concrete implementation) allow a unit test to achieve?
  9. What is a reasonable comparison between Moq and NSubstitute, another popular .NET mocking library?
  10. What does `.Verify()` let you check on a Moq mock, and why is this useful?
  11. What does `mockRepo.Setup(r => r.GetAllUsers()).Returns(new List<User> { user1, user2 });` demonstrate about controlling collection-returning methods with Moq?
  12. 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);`?
Gaps to close?
Read the curated Moq notes — core concepts, patterns, interview prep.
Moq notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web