Invalid call, the last call has been used or no call has been made

后端 未结 5 936
夕颜
夕颜 2021-01-07 19:12

I am getting this error when I try to set a mock to have PropertyBehavior():

System.InvalidOperationException: System.InvalidOperationEx

5条回答
  •  生来不讨喜
    2021-01-07 19:46

    I ran into this issue when I was trying to call an internal property (getter only) on an object in C#. In this case, adding .PropertyBehavior() did not help.

    My solution was to extract the logic out of the property and into an internal method which I then injected dependencies into this method (as parameters).

提交回复
热议问题