May 2018
Intermediate to advanced
300 pages
7h 35m
English
Instead of having mock objects creation code scattered across your tests, you can avoid repetitive code by using MockRepository, available in Moq for creating and verifying mocks in a single location, thereby ensuring that you can do mock configuration by setting CallBase, DefaultValue, and MockBehavior and verifying the the mocks in one place:
var mockRepository = new MockRepository(MockBehavior.Strict) { DefaultValue = DefaultValue.Mock };var loanRepository = repository.Create<ILoanRepository>(MockBehavior.Loose);var userRepository = repository.Create<IUserRepository>();mockRepository.Verify();
In the preceding code snippet, a mock repository is created with MockBehaviour.Strict, and two mock objects are created, each with ...