public void Dispose_CompletesSuccesfully_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.Dispose(); UseContext(context => { var item = Assert.Single(context.Set <HangfireQueuedJob>()); Assert.Null(item.FetchedAt); }); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_completed"))); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_disposed"))); instance.Dispose(); }
public void Dispose_CompletesSuccesfully_WhenItemAlreadyRemoved() { var queuedJob = new HangfireQueuedJob { Id = 1, JobId = 1, Queue = "queue", FetchedAt = DateTime.UtcNow, }; using var instance = new EFCoreFetchedJob(Storage, queuedJob); instance.Dispose(); UseContext(context => Assert.Empty(context.Set <HangfireQueuedJob>())); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_completed"))); Assert.True(Assert.IsType <bool>( instance.GetFieldValue("_disposed"))); instance.Dispose(); }