Mocking method results

前端 未结 6 1578
情歌与酒
情歌与酒 2021-02-08 16:00

I\'m trying to find a way to fake the result of a method called from within another method.

I have a \"LoadData\" method which calls a separate helper to get some data a

6条回答
  •  感情败类
    2021-02-08 16:46

    I would try something like this:

    public class MyClass(){
      public void LoadData(IHelper helper){
        SomeProperty = helper.GetSomeData();
     }
    

    This way you can mock up the helper class using for example MOQ.

提交回复
热议问题