Ejemplo n.º 1
0
        public void Dequeue_ReturnsFetchedJob_WithJobId()
        {
            MsmqUtils.EnqueueJobId("my-queue", "job-id");
            var queue = CreateQueue(MsmqTransactionType.Internal);

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

            Assert.Equal("job-id", fetchedJob.JobId);
        }
Ejemplo n.º 2
0
        public void Dequeue_ReturnsFetchedJob_FromOtherQueues_IfFirstAreEmpty()
        {
            MsmqUtils.EnqueueJobId("queue-2", "job-id");
            var queue = CreateQueue(MsmqTransactionType.Internal);

            var fetchedJob = queue.Dequeue(new[] { "queue-1", "queue-2" }, _token);

            Assert.Equal("job-id", fetchedJob.JobId);
        }
        public void GetEnqueuedJobIds_ReturnsCorrectResult_WhenJobIdIsLongValue()
        {
            MsmqUtils.EnqueueJobId("my-queue", (int.MaxValue + 1L).ToString());

            var api = CreateMonitoringApi();

            var result = api.GetEnqueuedJobIds("my-queue", 0, 1).ToArray();

            Assert.Equal(1, result.Length);
            Assert.Equal(int.MaxValue + 1L, result[0]);
        }
        public void GetEnqueuedAndFetchedCount_ReturnsCorrectCounters()
        {
            MsmqUtils.EnqueueJobId("my-queue", "1");
            MsmqUtils.EnqueueJobId("my-queue", "2");
            MsmqUtils.EnqueueJobId("another-queue", "3");

            var api = CreateMonitoringApi();

            var result = api.GetEnqueuedAndFetchedCount("my-queue");

            Assert.Equal(2, result.EnqueuedCount);
            Assert.Null(result.FetchedCount);
        }
        public void GetEnqueuedJobIds_ReturnsCorrectResult()
        {
            for (var i = 1; i <= 10; i++)
            {
                MsmqUtils.EnqueueJobId("my-queue", i.ToString());
            }
            var api = CreateMonitoringApi();

            var result = api.GetEnqueuedJobIds("my-queue", 3, 2).ToArray();

            Assert.Equal(2, result.Length);
            Assert.Equal(4, result[0]);
            Assert.Equal(5, result[1]);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }