public Task UnsubscribeContext() { var context = new TestableUnsubscribeContext { EventType = typeof(MyMessage) }; return(Verify(context)); }
public void Should_Throw_when_max_retries_reached() { var options = new UnsubscribeOptions(); var state = options.GetExtensions().GetOrCreate<MessageDrivenUnsubscribeTerminator.Settings>(); state.MaxRetries = 10; state.RetryDelay = TimeSpan.Zero; dispatcher.FailDispatch(11); var context = new TestableUnsubscribeContext { Extensions = options.Context }; Assert.That(async () => await terminator.Invoke(context, c => TaskEx.CompletedTask), Throws.InstanceOf<QueueNotFoundException>()); Assert.AreEqual(0, dispatcher.DispatchedTransportOperations.Count); Assert.AreEqual(11, dispatcher.FailedNumberOfTimes); }
public async Task Should_Dispatch_according_to_max_retries_when_dispatch_fails() { var options = new UnsubscribeOptions(); var state = options.GetExtensions().GetOrCreate<MessageDrivenUnsubscribeTerminator.Settings>(); state.MaxRetries = 10; state.RetryDelay = TimeSpan.Zero; dispatcher.FailDispatch(10); var context = new TestableUnsubscribeContext { Extensions = options.Context }; await terminator.Invoke(context, c => TaskEx.CompletedTask); Assert.AreEqual(1, dispatcher.DispatchedTransportOperations.Count); Assert.AreEqual(10, dispatcher.FailedNumberOfTimes); }
public void Should_Throw_when_max_retries_reached() { var options = new UnsubscribeOptions(); var state = options.GetExtensions().GetOrCreate <MessageDrivenUnsubscribeTerminator.Settings>(); state.MaxRetries = 10; state.RetryDelay = TimeSpan.Zero; dispatcher.FailDispatch(11); var context = new TestableUnsubscribeContext { Extensions = options.Context }; Assert.That(async() => await terminator.Invoke(context, c => Task.CompletedTask), Throws.InstanceOf <QueueNotFoundException>()); Assert.AreEqual(0, dispatcher.DispatchedTransportOperations.Count); Assert.AreEqual(11, dispatcher.FailedNumberOfTimes); }
public async Task Should_Dispatch_according_to_max_retries_when_dispatch_fails() { var options = new UnsubscribeOptions(); var state = options.GetExtensions().GetOrCreate <MessageDrivenUnsubscribeTerminator.Settings>(); state.MaxRetries = 10; state.RetryDelay = TimeSpan.Zero; dispatcher.FailDispatch(10); var context = new TestableUnsubscribeContext { Extensions = options.Context }; await terminator.Invoke(context, c => Task.CompletedTask); Assert.AreEqual(1, dispatcher.DispatchedTransportOperations.Count); Assert.AreEqual(10, dispatcher.FailedNumberOfTimes); }