How to mock a class that implements multiple interfaces

前端 未结 4 777
误落风尘
误落风尘 2020-12-05 17:19

How to mock the following class:

UserRepository : GenericRepository, IUserRepository


public class GenericRepository : IGenericRe         


        
4条回答
  •  星月不相逢
    2020-12-05 17:45

    You don't mock classes, you mock interfaces. In your case you could have two mocks - one that mocks IUserRepository and one that mocks IGenericRepository. They shouldn't necessarily be the same object - if they DO have to be the same object, then it may be a design flaw.

提交回复
热议问题