public async Task TestWith100Messages() { var responses = MakeResponses(100); var dummySQS = new FixedDataSqs(responses); int receivedCount = 0; async Task <bool> Handler(Message message) { await Task.Delay(50); Console.WriteLine($"Handled message {message.Body}"); Interlocked.Increment(ref receivedCount); return(true); } var wrappedHandler = Handlers.Wrap(Handler, dummySQS, OnTiming, OnException); var listener = new SimpleListener(dummySQS, wrappedHandler, CancelAfterSeconds(5), new NullListenerLogger()); await listener.Listen(); Assert.Equal(100, receivedCount); }
public async Task RunForASecond() { var dummySqs = new FixedDataSqs(Enumerable.Empty <ReceiveMessageResponse>()); var listener = new SimpleListener( dummySqs, Handler, CancelAfterSeconds(1), new NullListenerLogger()); await listener.Listen(); }
public async Task RunForFiveSeconds() { var dummySQS = new FixedDataSqs(Enumerable.Empty <ReceiveMessageResponse>()); var handler = Handlers.Wrap(Handler, dummySQS, OnTiming, OnException); var listener = new SimpleListener(dummySQS, handler, CancelAfterSeconds(5), new NullListenerLogger()); await listener.Listen(); }