Moq IServiceProvider / IServiceScope

前端 未结 5 1588
挽巷
挽巷 2021-02-01 14:01

I am trying to create a Mock (using Moq) for an IServiceProvider so that I can test my repository class:

public class ApiResourceRepository : IApiRe         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-01 14:59

    The general rule is that you don't mock types that you don't own. Unless you need to verify the calls made to the service provider, just build the IServiceProvider from a ServiceCollection in your tests.

提交回复
热议问题