如何断言"no calls to an object have been made"?

How to assert "no calls to an object have been made"?

如何使用 FakeItEasy 断言没有调用对象?

我试过了:

A.CallTo(() => _myObj).MustNotHaveHappened();

虽然这不起作用,但会抛出以下异常:

System.ArgumentException : The specified expression is not a method call or property getter.

怎么办?

使用Specify a call to configure any method or property中描述的机制,将假的传递给A.CallTo:

A.CallTo(_myObj).MustNotHaveHappened();