Exemplo n.º 1
0
    public async Task Enqueue_VoidMethod_ShouldSucceed()
    {
        var testStore  = new MemoryJobStore();
        var jobManager = new JobManager(testStore);
        var jobRunner  = new JobRunner(null !);

        await jobManager.EnqueueAsync(() => TestJobs.Job1(1));

        JobDescriptor?job = await testStore.NextAsync(CancellationToken.None);

        Assert.Equal("Job1", job !.Call.Method);
        jobRunner.Invoke(job.Call, CancellationToken.None);
    }
Exemplo n.º 2
0
    public async Task Enqueue_AsyncInstanceMethod_ShouldSucceed()
    {
        var testServiceProvider = new TestServiceProvider();
        var testStore           = new MemoryJobStore();
        var jobManager          = new JobManager(testStore);
        var jobRunner           = new JobRunner(testServiceProvider);

        await jobManager.EnqueueAsync <TestJobs>((t) => t.InstanceJobAsync1(1));

        JobDescriptor?job = await testStore.NextAsync(CancellationToken.None);

        Assert.Equal("InstanceJobAsync1", job !.Call.Method);
        await jobRunner.InvokeAsync(job.Call, CancellationToken.None);
    }
 /// <summary>
 /// Creates a new <see cref="IJobStore"/> instance for use with this test class.
 /// </summary>
 /// <returns>A <see cref="IJobStore"/> instance.</returns>
 private static IJobStore CreateJobStore()
 {
     IJobStore store = new MemoryJobStore();
     store.Initialize(null);
     return store;
 }