Exemple #1
0
    public void Enqueue_Throws_WhenJobNotExists()
    {
        var instance = new EFCoreJobQueue(Storage);
        var queue    = "queue";

        Assert.Throws <InvalidOperationException>(() => instance.Enqueue(queue, "1"));

        UseContext(context => Assert.Empty(context.Set <HangfireQueuedJob>()));
    }
Exemple #2
0
    public void Enqueue_Throws_WhenJobIdParameterIsNull()
    {
        var    instance = new EFCoreJobQueue(CreateStorageStub());
        var    queue    = "queue";
        string jobId    = null;

        Assert.Throws <ArgumentNullException>(nameof(jobId),
                                              () => instance.Enqueue(queue, jobId));
    }
Exemple #3
0
    public void Enqueue_Throws_WhenJobIdParameterIsInvalid()
    {
        var    instance = new EFCoreJobQueue(CreateStorageStub());
        var    queue    = "queue";
        string jobId    = "invalid";

        Assert.Throws <FormatException>(
            () => instance.Enqueue(queue, jobId));
    }
Exemple #4
0
    public void Enqueue_Throws_WhenQueueParameterIsEmpty()
    {
        var    instance = new EFCoreJobQueue(CreateStorageStub());
        string queue    = string.Empty;
        var    jobId    = "1";

        Assert.Throws <ArgumentException>(nameof(queue),
                                          () => instance.Enqueue(queue, jobId));
    }
Exemple #5
0
    public void Enqueue_CompletesSuccessfully_WhenJobExists()
    {
        var job = new HangfireJob
        {
            InvocationData = InvocationDataStub,
        };

        UseContextSavingChanges(context => context.Add(job));
        var instance = new EFCoreJobQueue(Storage);
        var queue    = "queue";

        instance.Enqueue(queue, job.Id.ToString(CultureInfo.InvariantCulture));

        UseContext(context =>
        {
            var actual = Assert.Single(context.Set <HangfireQueuedJob>());
            Assert.Equal(job.Id, actual.JobId);
            Assert.Equal(queue, actual.Queue);
            Assert.Null(actual.FetchedAt);
        });
    }