public async Task Should_deliver() { var payload = "some payload"; var delay = QueueDelayTime.Add(QueueDelayTime).Add(TimeSpan.FromSeconds(1)); var context = await Scenario.Define <Context>() .WithEndpoint <SendOnlySender>(b => b.When(async(session, c) => { var sendOptions = new SendOptions(); sendOptions.DelayDeliveryWith(delay); c.SentAt = DateTime.UtcNow; await session.Send(new DelayedMessage { Payload = payload }, sendOptions); })) .WithEndpoint <Receiver>() .Done(c => c.Received) .Run(); Assert.GreaterOrEqual(context.ReceivedAt - context.SentAt, delay, "The message has been received earlier than expected."); Assert.AreEqual(payload, context.Payload, "The received payload doesn't match the sent one."); }
public void Should_fail_to_send_message_if_above_queue_delay_time() { var delay = QueueDelayTime.Add(TimeSpan.FromSeconds(1)); Assert.ThrowsAsync <QueueDoesNotExistException>(async() => { await Scenario.Define <Context>() .WithEndpoint <SendOnlySender>(b => b.When(async(session, c) => { var sendOptions = new SendOptions(); sendOptions.DelayDeliveryWith(delay); await session.Send(new DelayedMessage { Payload = "" }, sendOptions); })) .Run(); }); }