public void HandlingLastErrorMessageCallsFallback() { var basicProperties = new BasicProperties(); basicProperties.SetRetryCount(3); var basicDeliverEventArgs = new BasicDeliverEventArgs(Guid.NewGuid().ToString(), 0, false, "Test", "Test", basicProperties, new byte[16]); _sut.HandleConsumerError(basicDeliverEventArgs, new Exception("Test")); Thread.Sleep(TimeSpan.FromSeconds(4)); _model.AssertWasNotCalled(x => x.BasicPublish(null, null, null, null), y => y.IgnoreArguments()); _fallbackStrategy.AssertWasCalled(x => x.HandleConsumerError(null, null), y => y.IgnoreArguments() .Message("Expected invocation of fallback strategy!")); _logger.AssertWasNotCalled(x => x.ErrorWrite(null, null), y => y.IgnoreArguments() .Message("RetryMessageConsumerErrorStrategy should not be called any more at this point!")); }
public void HandleSecondErroredMessage() { var basicProperties = new BasicProperties(); basicProperties.SetRetryCount(2); var basicDeliverEventArgs = new BasicDeliverEventArgs(Guid.NewGuid().ToString(), 0, false, "Test", "Test", basicProperties, new byte[16]); _sut.HandleConsumerError(basicDeliverEventArgs, new Exception("Test")); Thread.Sleep(TimeSpan.FromSeconds(4)); _model.AssertWasCalled(x => x.BasicPublish(Arg<string>.Is.Equal("Test"), Arg<string>.Is.Equal("Test"), Arg<IBasicProperties>.Matches(z => z.GetRetryCount() == 3), Arg<byte[]>.Is.Anything)); _logger.AssertWasNotCalled(x => x.ErrorWrite(null, null), y => y.IgnoreArguments()); }