コード例 #1
0
    private void runJobs(string storageConnectionString)
    {
        var system = new SystemUnderInfraTest();

        system.UseOptions(new ConfigurationOptions
        {
            ConnectionString     = ConnectionString,
            UpdateConfigurations = new[]
            {
                new UpdateStorageConfiguration
                {
                    ConnectionString = storageConnectionString,
                    Name             = DefaultConfigurationName.Name()
                }
            }
        })
        .UseServerOptions(new BackgroundJobServerOptions
        {
            Queues = _queues
        });
        system.UseRealHangfire();
        FakeJobService.Reset();

        var publisher = system.QueryPublishers().Single();

        publisher.BackgroundJobClient.Enqueue(() => FakeJobService.DefaultQueueJob());
        publisher.BackgroundJobClient.Enqueue(() => FakeJobService.AQueueJob());
        WorkerEmulation.SingleIteration(publisher.JobStorage, _queues);
        WorkerEmulation.SingleIteration(publisher.JobStorage, _queues);
    }
コード例 #2
0
    private void enqueuedJobOnWorker(string storageConnstring)
    {
        var system = new SystemUnderInfraTest();

        system.UseOptions(new ConfigurationOptions
        {
            ConnectionString     = ConnectionString,
            UpdateConfigurations = new[]
            {
                new UpdateStorageConfiguration
                {
                    ConnectionString = storageConnstring,
                    Name             = DefaultConfigurationName.Name()
                }
            }
        });
        system.UseRealHangfire();
        FakeJobService.Reset();

        var publisher = system.QueryPublishers().Single();

        publisher.BackgroundJobClient.Enqueue(() => FakeJobService.RunTheJob());
        WorkerEmulation.SingleIteration(publisher.JobStorage);

        FakeJobService.WasRun.Should().Be.True();
    }