Moq fake one method but use real implementation of another

前端 未结 2 1117
北荒
北荒 2021-02-06 21:31

Given an interface IService that has Method1() and Method2().

I want to test that when Method1() throws an Exce

2条回答
  •  被撕碎了的回忆
    2021-02-06 22:08

    In this case (unless there's a lot more going on) I would just create my own test class extending the class with the real behavior, that implements the interface you need to mock. This way you can mock the one value, and fallback to the base class for the real functionality.

提交回复
热议问题