public void RemoveFromQueue_WhenItemExists() { var job = new HangfireJob { InvocationData = InvocationDataStub, QueuedJobs = new List <HangfireQueuedJob> { new HangfireQueuedJob { Queue = "queue", FetchedAt = DateTime.UtcNow, }, }, }; UseContextSavingChanges(context => context.Add(job)); using var instance = new EFCoreFetchedJob(Storage, job.QueuedJobs.Single()); instance.RemoveFromQueue(); UseContext(context => { Assert.Single(context.Set <HangfireJob>()); Assert.Empty(context.Set <HangfireQueuedJob>()); }); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_completed"))); Assert.False(Assert.IsType <bool>( instance.GetFieldValue("_disposed"))); }
public void RemoveFromQueue_WhenItemAlreadyRemoved() { var item = new HangfireQueuedJob { Id = 1, Queue = "queue", FetchedAt = DateTime.UtcNow, }; using var instance = new EFCoreFetchedJob(Storage, item); instance.RemoveFromQueue(); UseContext(context => Assert.Empty(context.Set <HangfireQueuedJob>())); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_completed"))); Assert.False(Assert.IsType <bool>( instance.GetFieldValue("_disposed"))); }