public void Ctor_CreatesInstance() { var queuedJob = new HangfireQueuedJob { Id = 1, JobId = 2, Queue = "queue", }; using var instance = new EFCoreFetchedJob(Storage, queuedJob); Assert.False(Assert.IsType <bool>( instance.GetFieldValue("_disposed"))); Assert.False(Assert.IsType <bool>( instance.GetFieldValue("_completed"))); Assert.Same(Storage, Assert.IsType <EFCoreStorage>( instance.GetFieldValue("_storage"))); Assert.Same(queuedJob, Assert.IsType <HangfireQueuedJob>( instance.GetFieldValue("_queuedJob"))); Assert.Equal(queuedJob.Id, instance.Id); Assert.Equal(queuedJob.JobId, instance.JobId); Assert.Equal(queuedJob.Queue, instance.Queue); Assert.Equal (queuedJob.JobId.ToString(CultureInfo.InvariantCulture), ((IFetchedJob)instance).JobId); }
public static void Ctor_Throws_WhenStorageParameterIsNull() { EFCoreStorage storage = null; var queuedJob = new HangfireQueuedJob(); Assert.Throws <ArgumentNullException>(nameof(storage), () => new EFCoreFetchedJob(storage, queuedJob)); }
public void Ctor_Throws_WhenItemParameterIsNull() { var storage = CreateStorageStub(); HangfireQueuedJob queuedJob = null; Assert.Throws <ArgumentNullException>(nameof(queuedJob), () => new EFCoreFetchedJob(storage, queuedJob)); }
private static void AddJobWithQueueItemToContext(HangfireContext context, string queue) { var job = new HangfireJob { CreatedAt = DateTime.UtcNow, InvocationData = CreateInvocationData(() => SampleMethod(null)), }; var queueItem = new HangfireQueuedJob { Job = job, Queue = queue, }; context.Add(job); context.Add(queueItem); }
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"))); }