示例#1
0
        public void DisposeWithoutRemoval_OnFetchedJob_ReturnsTheJobToTheQueue()
        {
            // Arrange
            MsmqUtils.EnqueueJobId("my-queue", "job-id");
            var queue = CreateQueue(MsmqTransactionType.Internal);

            // Act
            var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token);

            fetchedJob.Dispose();

            // Assert
            var jobId = MsmqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(5));

            Assert.Equal("job-id", jobId);
        }
示例#2
0
        public void Dequeue_MakesJobInvisibleForOtherFetchers()
        {
            // Arrange
            MsmqUtils.EnqueueJobId("my-queue", "job-id");
            var queue = CreateQueue(MsmqTransactionType.Internal);

            // Act
            var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token);

            // Assert
            Assert.NotNull(fetchedJob);

            var exception = Assert.Throws <MessageQueueException>(
                () => MsmqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(1)));

            Assert.Equal(MessageQueueErrorCode.IOTimeout, exception.MessageQueueErrorCode);
        }
示例#3
0
        public void RemoveFromQueue_OnFetchedJob_RemovesTheJobCompletely()
        {
            // Arrange
            MsmqUtils.EnqueueJobId("my-queue", "job-id");
            var queue = CreateQueue(MsmqTransactionType.Internal);

            // Act
            using (var fetchedJob = queue.Dequeue(new[] { "my-queue" }, _token))
            {
                fetchedJob.RemoveFromQueue();
            }

            // Assert
            var exception = Assert.Throws <MessageQueueException>(
                () => MsmqUtils.DequeueJobId("my-queue", TimeSpan.FromSeconds(5)));

            Assert.Equal(MessageQueueErrorCode.IOTimeout, exception.MessageQueueErrorCode);
        }