Created
August 18, 2017 21:23
-
-
Save derekgreer/f29e5a783b0a3b00b14c49bf13a5d99c to your computer and use it in GitHub Desktop.
Test Spy API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RetryConsumerFilterSpecs | |
{ | |
[Subject("Message Retry")] | |
public class when_a_handler_throws_an_exception_that_should_not_be_retried | |
{ | |
static Action<IConsumeContext<string>> _nextStub; | |
static RetryConsumerFilter _filter; | |
static Exception _exception; | |
static Spy<IConsumeContext<string>> _consumeContextSpy; | |
Establish context = () => | |
{ | |
_nextStub = c => throw new Exception(); | |
_consumeContextSpy = new Spy<IConsumeContext<string>>().Configure((spy, inquiries) => | |
{ | |
spy.Setup(x => x.RetryCount).Returns(0); | |
spy.Setup(x => x.RetryLater()).Callback(() => inquiries.Answer("was enqueued?", true)); | |
}); | |
_filter = new RetryConsumerFilter(new MessageBusOptions { MaxRetryCount = 0 }); | |
}; | |
Because of = () => _exception = Catch.Exception(() => _filter.Consume(_consumeContextSpy.Object, _nextStub)); | |
It should_rethrow_the_exception = () => _exception.ShouldNotBeNull(); | |
It should_not_enqueue_the_message = () => _consumeContextSpy.Ask<bool>("was enqueued?").ShouldBeFalse(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment