How to mock a web service

前端 未结 4 1592
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 13:09

Do I have to rewrite my code to do this into an interface? Or is there an easier way? I am using Moq

4条回答
  •  臣服心动
    2020-12-25 13:27

    I blogged about this a long time ago. Basically using partial classes and a bit of effort (either automated or manual, depending on how often you're going to change the web service) you can make the web service proxy class implement an interface. You can then mock it as normal.

提交回复
热议问题