Skip to content
Tracon

JobHandlerContract

Namespace Tracon.Testing.Contracts.Scheduling · Assembly Tracon.Testing.Contracts.Xunit.dll

Behavior tests for the IJobHandler at-least-once contract: a handler must not reprocess an item already reported, and must observe cancellation between items.

public abstract class JobHandlerContract : IAsyncLifetime, IAsyncDisposable

objectJobHandlerContract

IAsyncLifetime, IAsyncDisposable

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

protected JobHandlerContract()

The handler under test.

protected IJobHandler Handler { get; }

IJobHandler

The handler key the job records this contract builds carry. Override when the handler under test needs its real key (a built-in one from JobHandlerKeys, or the consumer’s own); the value never reaches dispatch here, because the contract calls the handler directly.

protected virtual string HandlerKey { get; }

string

The job identifier shared by every JobContext built during this instance’s tests. A handler that keys other state by job id (an eval run record, for example) can create that state against this value inside JobHandlerContract.CreateHandlerAsync.

protected Guid JobId { get; }

Guid

[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/Scheduling/JobHandlerContract.cs", 93)]
public Task Cancellation_is_observed_between_items()

Task

Completed_items_are_not_processed_again()

Section titled “ Completed_items_are_not_processed_again()”
[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/Scheduling/JobHandlerContract.cs", 69)]
public Task Completed_items_are_not_processed_again()

Task

Creates the handler under test, performing whatever async setup it needs (an eval suite and run record, a workflow registration, and so on).

protected abstract ValueTask<IJobHandler> CreateHandlerAsync()

ValueTask<IJobHandler>

Creates one job item the handler under test can process.

protected abstract JobItemRecord CreateItem(int sequence, JobItemStatus status)

sequence int

The item’s position within the job.

status JobItemStatus

The item’s starting status.

JobItemRecord

Builds the job record wrapping items. Override to set a specific target name or payload the handler under test needs.

protected virtual JobRecord CreateJob(IReadOnlyList<JobItemRecord> items)

items IReadOnlyList<JobItemRecord>

JobRecord

public ValueTask DisposeAsync()

ValueTask

Called immediately after the class has been created, before it is used.

public ValueTask InitializeAsync()

ValueTask

Only_pending_items_are_processed_on_a_retry()

Section titled “ Only_pending_items_are_processed_on_a_retry()”
[Fact("/Users/farukatasoy/Desktop/projects/Tracon/src/Tracon.Testing.Contracts.Xunit/Contracts/Scheduling/JobHandlerContract.cs", 79)]
public Task Only_pending_items_are_processed_on_a_retry()

Task