public void Requeue_RemovesTheFetchedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.HashSet(Prefix + "job:my-job", "Fetched", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue", Prefix);

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashExists(Prefix + "job:my-job", "Fetched"));
            });
        }
        public void Dispose_WithNoComplete_RequeuesAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(1, redis.ListLength("hangfire:queue:my-queue"));
            });
        }
        public void Requeue_PushesAJobBackToQueue()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal("my-job", (string)redis.ListRightPop("hangfire:queue:my-queue"));
            });
        }
Example #4
0
        public void Requeue_RemovesAJobFromFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal(0, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
            });
        }
Example #5
0
        public void Dispose_WithNoComplete_RequeuesAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue"));
            });
        }
Example #6
0
        public void Requeue_PushesAJobBackToQueue()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal("my-job", redis.RemoveEndFromList("hangfire:queue:my-queue"));
            });
        }
        public void Requeue_RemovesAJobFromFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal(0, redis.ListLength("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void Requeue_RemovesTheCheckedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.HashSet("hangfire:job:my-job", "Checked", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashExists("hangfire:job:my-job", "Checked"));
            });
        }
Example #9
0
        public void Requeue_RemovesTheFetchedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.HSet("{hangfire}:job:my-job", "Fetched", "value");
                var fetchedJob = new RedisFetchedJob(_storage, redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HExists("{hangfire}:job:my-job", "Fetched"));
            });
        }
Example #10
0
        public void Dispose_WithNoComplete_RequeuesAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.RPush("{hangfire}:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(_storage, redis, "my-job", "my-queue");

                // Act
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(1, redis.LLen("{hangfire}:queue:my-queue"));
            });
        }
Example #11
0
        public void Requeue_RemovesAJobFromFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.RPush("{hangfire}:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(_storage, redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal(0, redis.LLen("{hangfire}:queue:my-queue:dequeued"));
            });
        }
Example #12
0
        public void Requeue_RemovesTheFetchedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.SetEntryInHash("hangfire:job:my-job", "Fetched", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashContainsEntry("hangfire:job:my-job", "Fetched"));
            });
        }
Example #13
0
        public void RemoveFromQueue_RemovesJobFromTheFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("{hangfire}:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(_storage, redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(0, redis.ListLength("{hangfire}:queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesJobFromTheFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(0, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesJobFromTheFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListLeftPush(Prefix + "queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue", Prefix);

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(0, redis.ListLength(Prefix + "queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesJobFromTheFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(0, redis.ListLength("hangfire:queue:my-queue:dequeued"));
            });
        }
Example #17
0
        public void Requeue_PushesAJobToTheRightSide()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue", "another-job");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");

                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert - RPOP
                Assert.Equal("my-job", redis.RemoveEndFromList("hangfire:queue:my-queue"));
            });
        }
        public void Dispose_AfterRemoveFromQueue_DoesNotRequeueAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(0, redis.ListLength("hangfire:queue:my-queue"));
            });
        }
Example #19
0
        public void RemoveFromQueue_RemovesOnlyOneJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.RPush("{hangfire}:queue:my-queue:dequeued", "job-id");
                redis.RPush("{hangfire}:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(_storage, redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.LLen("{hangfire}:queue:my-queue:dequeued"));
            });
        }
Example #20
0
        public void RemoveFromQueue_RemovesOnlyOneJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "job-id");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesOnlyOneJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "job-id");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.ListLength("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void Requeue_PushesAJobToTheRightSide()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("{hangfire}:queue:my-queue", "another-job");
                redis.ListRightPush("{hangfire}:queue:my-queue:dequeued", "my-job");

                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert - RPOP
                Assert.Equal("my-job", (string)redis.ListRightPop("{hangfire}:queue:my-queue"));
            });
        }
        public void RemoveFromQueue_RemovesOnlyJobWithTheSpecifiedId()
        {
            UseRedis(redis =>
            {
                // Arrange
				redis.ListRightPush("hangfire:queue:my-queue:dequeued", "job-id");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "another-job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.ListLength("hangfire:queue:my-queue:dequeued"));
                Assert.Equal("another-job-id", (string)redis.ListRightPop("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesOnlyJobWithTheSpecifiedId()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "job-id");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "another-job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.ListLength("hangfire:queue:my-queue:dequeued"));
                Assert.Equal("another-job-id", (string)redis.ListRightPop("hangfire:queue:my-queue:dequeued"));
            });
        }
        public void RemoveFromQueue_RemovesOnlyJobWithTheSpecifiedId()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "job-id");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "another-job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
                Assert.Equal("another-job-id", redis.DequeueItemFromList("hangfire:queue:my-queue:dequeued"));
            });
        }
Example #26
0
        public void RemoveFromQueue_RemovesOnlyJobWithTheSpecifiedId()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "job-id");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "another-job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
                Assert.Equal("another-job-id", redis.DequeueItemFromList("hangfire:queue:my-queue:dequeued"));
            });
        }
Example #27
0
        public void Requeue_DoesntDuplicateDequeued()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("{hangfire}:queue:my-queue:dequeued", "my-job");
                redis.ListRightPush(MY_QUEUE_KEY, "my-job");
                var fetchedJob = new RedisFetchedJob(_storage, redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                var length = redis.ListLength(MY_QUEUE_KEY);
                Assert.Equal(1, length);

                // Assert
                Assert.Equal("my-job", (string)redis.ListRightPop(MY_QUEUE_KEY));
            });
        }
        public void Requeue_PushesAJobBackToQueue()
        {
            UseRedis(redis => 
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal("my-job", redis.RemoveEndFromList("hangfire:queue:my-queue"));
            });
        }
        public void Dispose_AfterRemoveFromQueue_DoesNotRequeueAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
				redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.RemoveFromQueue();
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(0, redis.ListLength("hangfire:queue:my-queue"));
            });
        }
        public void Requeue_RemovesAJobFromFetchedList()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush(Prefix + "queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue", Prefix);

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal(0, redis.ListLength(Prefix + "queue:my-queue:dequeued"));
            });
        }
        public void Requeue_RemovesTheCheckedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.HashSet("hangfire:job:my-job", "Checked", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashExists("hangfire:job:my-job", "Checked"));
            });
        }
        public void Dispose_WithNoComplete_RequeuesAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(1, redis.ListLength("hangfire:queue:my-queue"));
            });
        }
        public void Requeue_RemovesTheFetchedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.HashSet(Prefix + "job:my-job", "Fetched", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue", Prefix);

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashExists(Prefix + "job:my-job", "Fetched"));
            });
        }
        public void Requeue_PushesAJobToTheRightSide()
        {
            UseRedis(redis =>
            {
                // Arrange
				redis.ListRightPush("hangfire:queue:my-queue", "another-job");
                redis.ListRightPush("hangfire:queue:my-queue:dequeued", "my-job");

                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert - RPOP
                Assert.Equal("my-job", (string)redis.ListRightPop("hangfire:queue:my-queue")); 
            });
        }
        public void RemoveFromQueue_RemovesOnlyOneJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.ListRightPush(Prefix + "queue:my-queue:dequeued", "job-id");
                redis.ListRightPush(Prefix + "queue:my-queue:dequeued", "job-id");

                var fetchedJob = new RedisFetchedJob(redis, "job-id", "my-queue", Prefix);

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                Assert.Equal(1, redis.ListLength(Prefix + "queue:my-queue:dequeued"));
            });
        }
        public void Requeue_PushesAJobBackToQueue()
        {
            UseRedis(redis => 
            {
                // Arrange
                redis.ListRightPush(Prefix + "queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue", Prefix);

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.Equal("my-job", redis.ListRightPop(Prefix + "queue:my-queue"));
            });
        }
        public void Requeue_PushesAJobToTheRightSide()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue", "another-job");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");

                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert - RPOP
                Assert.Equal("my-job", redis.RemoveEndFromList("hangfire:queue:my-queue")); 
            });
        }
        public void Requeue_RemovesTheFetchedFlag()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.SetEntryInHash("hangfire:job:my-job", "Fetched", "value");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Requeue();

                // Assert
                Assert.False(redis.HashContainsEntry("hangfire:job:my-job", "Fetched"));
            });
        }
        public void Dispose_WithNoComplete_RequeuesAJob()
        {
            UseRedis(redis =>
            {
                // Arrange
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                var fetchedJob = new RedisFetchedJob(redis, "my-job", "my-queue");

                // Act
                fetchedJob.Dispose();

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue"));
            });
        }