我想断言没有被派往,又名_dispatcher.Dispatch
不叫。如何使用FakeItEasy断言的方法不叫
interface
被伪造/嘲笑:
interface IDispatcher
{
void Dispatch<T>(T command,
Stuff stuff = null,
TimeSpan? timeout = null,
int? retries = null) where T : Command;
}
在人体试验:
_dispatcher = A.Fake<IDispatcher>();
// do stuff
A.CallTo(() => _dispatcher.Dispatch(A<Command>.Ignored,
A<Stuff>.Ignored,
A<TimeSpan?>.Ignored,
A<int?>.Ignored)).MustNotHaveHappened();
这测试通过时东西被派往。
任何想法?我错误地使用FakeItEasy?
你最可能设置了错误的CallTo()。例如:你确定你想要A ._而不是A ._作为第二个参数吗? –
你有没有尝试过呢? .MustHaveHappened()是否在派发事物时工作?我猜不是。 –
你确定你正在拨打'Dispatch'吗?此外,'DispatchWork'和'Dispatch '是两种不同的方法。 –
PoweredByOrange