如何测试Bus.Defer()

时间:2015-03-02 16:49:27

标签: unit-testing nservicebus

是否有人知道如果Bus.Defer()发生了?(在单元测试中)?这似乎还不够:

Test.Saga<TSaga>(mySaga).ExpectSend < MessageThatIsDeferred >()

结果是:

ExpectedSendInvocation< MessageThatIsDeferred > not fulfilled

致电:

DeferMessageInvocation< MessageThatIsDeferred,System.DateTime >

1 个答案:

答案 0 :(得分:4)

您似乎正在使用Saga,在这种情况下,您应该致电RequestTimeout,请参阅http://docs.particular.net/nservicebus/sagas-in-nservicebus#timeouts

测试传奇超时是一个例子:

Test.Saga<TimeoutSaga>()
            .ExpectTimeoutToBeSetIn<MyTimeout>()
            .When(saga => saga.Handle(new StartMessage()));

这有意义吗?