public void ProcessAsync_ExceptionWhileProcessingItem_ThrowException() { var queue = new SingleItemQueue(new StringItem("An item")); var handler = new ThrowExceptionPayloadHandler(new Exception("An exception")); var queueProcessor = new DefaultQueueProcessor <string>(queue, handler); Assert.ThrowsAsync <Exception>(() => queueProcessor.ProcessAsync()); }
public async Task ProcessAsync_AnItemInQueue_ReturnsTrue() { var queue = new SingleItemQueue(new StringItem("An item")); var handler = new FakePayloadHandler(); var queueProcessor = new DefaultQueueProcessor <string>(queue, handler); var processed = await queueProcessor.ProcessAsync(); Assert.IsTrue(processed); }
public async Task ProcessAsync_EmptyQueue_ReturnsFalse() { var queue = new EmptyQueue(); var handler = new FakePayloadHandler(); var queueProcessor = new DefaultQueueProcessor <string>(queue, handler); var processed = await queueProcessor.ProcessAsync(); Assert.IsFalse(processed); }
public async Task ProcessAsync_SingleItemInQueue_ProcessesAndEmptiesQueue() { using (var scope = new IsolationScope(TestFixtureContext.Provider)) { var connection = scope.Provider.GetRequiredService <IDbConnection>(); await connection.ExecuteSqlAsync("INSERT INTO Kiukie.Queue(Payload) VALUES(@Payload)", new StringItem("An item")); var queue = new DefaultQueue <string>(connection); var handler = new FakePayloadHandler(); var queueProcessor = new DefaultQueueProcessor <string>(queue, handler); var processed = await queueProcessor.ProcessAsync(); Assert.IsTrue(processed); processed = await queueProcessor.ProcessAsync(); Assert.IsFalse(processed); } }