public void DisposeWithoutRemoval_OnFetchedJob_ReturnsTheJobToTheQueue() { // Arrange RabbitMqUtils.EnqueueJobId("my-queue", "job-id"); using (var queue = CleanRabbitMqQueueAttribute.GetMessageQueue("my-queue")) { // Act var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token); fetchedJob.Dispose(); // Assert var jobId = RabbitMqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(5)); Assert.Equal("job-id", jobId); } }
public void RemoveFromQueue_OnFetchedJob_RemovesTheJobCompletely() { // Arrange RabbitMqUtils.EnqueueJobId("my-queue", "job-id"); using (var queue = CleanRabbitMqQueueAttribute.GetMessageQueue("my-queue")) { // Act using (var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token)) { fetchedJob.RemoveFromQueue(); } // Assert var exception = Assert.Throws <TimeoutException>( () => RabbitMqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(1))); Assert.Equal(exception.Message, "my-queue"); } }
public void Dequeue_MakesJobInvisibleForOtherFetchers() { // Arrange RabbitMqUtils.EnqueueJobId("my-queue", "job-id9"); using (var queue = CleanRabbitMqQueueAttribute.GetMessageQueue("my-queue")) { // Act var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token); // Assert Assert.NotNull(fetchedJob); var exception = Assert.Throws <TimeoutException>( () => RabbitMqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(1))); Assert.Equal(exception.Message, "my-queue"); } }