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"))); } }
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")); } }
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")); } }
public FetchedJobsWatcherFacts() { _storage = new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb()); _cts = new CancellationTokenSource(); _cts.Cancel(); }
public RedisTest() { _redis = RedisUtils.CreateClient(); }
public FetchedJobsWatcherFacts() { _storage = new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb()); _token = new CancellationToken(true); }
private RedisStorage CreateStorage() { return(new RedisStorage(RedisUtils.GetHostAndPort(), RedisUtils.GetDb())); }