示例#1
0
        public void Execute_MarksDequeuedJobAsChecked_IfItHasNoFetchedFlagSet()
        {
            using (var redis = RedisUtils.CreateClient())
            {
                // Arrange
                redis.AddItemToSet("hangfire:queues", "my-queue");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");

                var watcher = CreateWatcher();

                // Act
                watcher.Execute(_cts.Token);

                Assert.NotNull(JobHelper.DeserializeNullableDateTime(
                                   redis.GetValueFromHash("hangfire:job:my-job", "Checked")));
            }
        }
示例#2
0
        public void Execute_DoesNotEnqueueTimedOutByCheckedFlagJob_IfFetchedFlagSet()
        {
            using (var redis = RedisUtils.CreateClient())
            {
                // Arrange
                redis.AddItemToSet("hangfire:queues", "my-queue");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                redis.SetEntryInHash("hangfire:job:my-job", "Checked",
                                     JobHelper.SerializeDateTime(DateTime.UtcNow.AddDays(-1)));
                redis.SetEntryInHash("hangfire:job:my-job", "Fetched",
                                     JobHelper.SerializeDateTime(DateTime.UtcNow));

                var watcher = CreateWatcher();

                // Act
                watcher.Execute(_cts.Token);

                // Assert
                Assert.Equal(1, redis.GetListCount("hangfire:queue:my-queue:dequeued"));
            }
        }
示例#3
0
        public void Execute_EnqueuesCheckedAndTimedOutJob_IfNoFetchedFlagSet()
        {
            using (var redis = RedisUtils.CreateClient())
            {
                // Arrange
                redis.AddItemToSet("hangfire:queues", "my-queue");
                redis.AddItemToList("hangfire:queue:my-queue:dequeued", "my-job");
                redis.SetEntryInHash("hangfire:job:my-job", "Checked",
                                     JobHelper.SerializeDateTime(DateTime.UtcNow.AddDays(-1)));

                var watcher = CreateWatcher();

                // Act
                watcher.Execute(_cts.Token);

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

                var job = redis.GetAllEntriesFromHash("hangfire:job:my-job");
                Assert.False(job.ContainsKey("Checked"));
            }
        }
示例#4
0
 public FetchedJobsWatcherFacts()
 {
     _storage = new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb());
     _cts     = new CancellationTokenSource();
     _cts.Cancel();
 }
示例#5
0
 public RedisTest()
 {
     _redis = RedisUtils.CreateClient();
 }
示例#6
0
 public FetchedJobsWatcherFacts()
 {
     _storage = new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb());
     _token   = new CancellationToken(true);
 }
示例#7
0
 private RedisStorage CreateStorage()
 {
     return(new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb()));
 }