public async Task Should_sum_categories() { config.Execution.ItemFailureCountToStopJob = 10; config.Categories = new DiagnosticConfig.Category[] { new DiagnosticConfig.Category() { IsSuccessful = true, Count = 5, Name = "Good" }, new DiagnosticConfig.Category() { IsSuccessful = true, Count = 4, Name = "Great" }, new DiagnosticConfig.Category() { IsSuccessful = false, Count = 3, Name = "Nah" }, new DiagnosticConfig.Category() { IsSuccessful = false, Count = 2, Name = "Bruh" } }; using var run = testHost.BuildRunner(); await run.RunAsync(); run.Execution.ItemCategories.Should().BeEquivalentTo(new[] { new ItemCategory(5, true, "Good"), new ItemCategory(4, true, "Great"), new ItemCategory(3, false, "Nah"), new ItemCategory(2, false, "Bruh") }, o => o.WithoutStrictOrdering()); }
public async Task Should_not_handle_failure_in_initialize() { config.ThrowExceptionInInitializeAsync = true; using var runner = testHost.BuildRunner(); (await runner.Invoking(a => a.RunAsync()) .Should().ThrowAsync <DiagnosticJobException>()) .And.Location.Should().Be(JobMethod.InitializeAsync); }
public async Task Should_cancel_running_job() { // Hold the job on the first item in ProcessAsync until Signal is called config.WaitForSignalInProcessAsync = true; using var run = testHost.BuildRunner(); var running = run.RunAsync(); run.Cancel(); // Don't wait after the first call config.WaitForSignalInProcessAsync = false; run.Job.Signal(); await running; run.Execution.IsCanceled.Should().BeTrue(); run.Execution.CanceledAt.Should().NotBeNull(); run.Execution.Disposition.Should().Be(Disposition.Cancelled); run.Execution.SuccessfulItemCount.Should().BeLessThan(run.Execution.TotalItemCount.Value); run.Results.FinalizeAsync.IsSuccessful.Should().BeTrue(); }
public async Task Should_say_hello() { using var runner = host.BuildRunner(); config.Names = new[] { "Rick", "Morty" }; await runner.RunAsync(); var logger = (FakeLogger <HelloWorld>)runner.Services.GetRequiredService <ILogger <HelloWorld> >(); logger.Logs.Should().Contain("Hello, Rick"); logger.Logs.Should().Contain("Hello, Morty"); }
public async Task Should_handle_failure_in_initialize() { config.ThrowExceptionInInitializeAsync = true; using var runner = testHost.BuildRunner(); var run = await runner.RunAsync(); run.Job.InitializedAt.Should().NotBeNull(); run.Job.ItemsRetrievedAt.Should().BeNull(); run.Job.ProcessedAt.Should().BeNull(); run.Job.FinalizedAt.Should().NotBeNull(); run.Execution.IsFailed.Should().BeTrue(); run.Execution.Disposition.Should().Be(Disposition.Failed); run.Results.InitializeAsync.IsSuccessful.Should().BeFalse(); run.Results.InitializeAsync.Exception.Should().NotBeNull(); run.Results.GetItemsAsync.Should().BeNull(); run.Results.Items.Count().Should().Be(0); run.Results.FinalizeAsync.IsSuccessful.Should().BeTrue(); }