[rabbitmq-discuss] [dotnet-client] Help mocking IModel.BasicPublish

Tim Watson tim at rabbitmq.com
Tue May 28 15:22:07 BST 2013

Hi Mark,

On 24 May 2013, at 17:02, Mark Snelling wrote:

> I've managed to successfully implement reading from a mocked call to IModel.BasicConsume() and acknowledging with IModel.BasicAck() but am stuck on IModel.BasicPublish(), in particular mocking the ack/nack mechanism with IModel as I need to test my component in both those scenarios.
> How does the ack/nack mechanism work with IModel.WaitForConfirms() and how would I go about sending an ack/nack when the publisher calls IModel.BasicPublish()?

It really depends on how you've mocked the model reference, but essentially the broker will send either ACK for one (or more, if batching) or NACK for the published messages, depending on whether or not it was willing and able to take responsibility for them. Presumably in your test cases you want to handle the situation where #WaitForConfirms() fails, in which case you should either return false (where you wish to simulate the broker issuing a NACK) or return true but also set the out parameter 'timedOut' to true to indicate that a timeout occurred.

Hope that makes sense.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130528/995f5a11/attachment.htm>

More information about the rabbitmq-discuss mailing list