TestableMessageHandlerContext and delayed commands

How do I test if a Command sent from a MessageHandler is delayed as expected? (DelayDeliveryWith)

Hi @Stig_Christensen

The SentMessages property returns SentMessage<object>. From there, you can access the Options property to get access to the SendOptions. Then you use GetDispatchProperties to extract the DelayDeliveryWith settings.

var dispatchProperties = context.SentMessages.Single().Options.GetDispatchProperties();

Assert.That(dispatchProperties.DelayDeliveryWith.Delay, Is.EqualTo(TimeSpan.FromDays(1)));

Hope that helps.

Regards,
Daniel