How to verify that method was NOT called in Moq?

前端 未结 5 1984
挽巷
挽巷 2020-12-22 16:48

How do I verify that method was NOT called in Moq?

Does it have something like AssertWasNotCalled?

UPDATE: Starting from Version 3.0, a new syntax can be us

5条回答
  •  独厮守ぢ
    2020-12-22 17:38

    Use .AtMostOnce();

    After the real test, call the method again. If it throws an exception, it was called.

提交回复
热议问题