Class ActivityEnvironment
- Namespace
- Temporalio.Testing
- Assembly
- Temporalio.dll
Testing environment which populates the ActivityExecutionContext for test code.
public record ActivityEnvironment : IEquatable<ActivityEnvironment>
- Inheritance
-
ActivityEnvironment
- Implements
- Inherited Members
Fields
DefaultInfo
Default activity info.
public static readonly ActivityInfo DefaultInfo
Field Value
Properties
CancelReason
Gets or sets the cancel reason. Callers should use one of the overloads of Cancel() instead.
public ActivityCancelReason CancelReason { get; set; }
Property Value
CancellationDetails
Gets or sets the cancellation details. Callers should use one of the overloads of Cancel() instead.
public ActivityCancellationDetails? CancellationDetails { get; set; }
Property Value
CancellationTokenSource
Gets or inits the cancellation token source.
public CancellationTokenSource CancellationTokenSource { get; init; }
Property Value
Heartbeater
Gets or inits the heartbeat callback. Default is a no-op callback.
public Action<object?[]> Heartbeater { get; init; }
Property Value
Info
Gets or inits the activity info. Default is DefaultInfo.
public ActivityInfo Info { get; init; }
Property Value
Logger
Gets or inits the logger. Default is a no-op logger.
public ILogger Logger { get; init; }
Property Value
MetricMeter
Gets or inits the metric meter for this activity. If unset, a noop meter is used.
public MetricMeter? MetricMeter { get; init; }
Property Value
PayloadConverter
Gets or inits the payload converter. Default is default converter.
public IPayloadConverter PayloadConverter { get; init; }
Property Value
TemporalClient
Gets or inits the Temporal client accessible from the activity context. If unset, an exception is thrown when the client is accessed.
public ITemporalClient? TemporalClient { get; init; }
Property Value
WorkerShutdownTokenSource
Gets or inits the worker shutdown token source.
public CancellationTokenSource WorkerShutdownTokenSource { get; init; }
Property Value
Methods
Cancel()
If cancellation not already requested, set the cancel reason/details and cancel the token source.
public void Cancel()
Cancel(ActivityCancelReason)
If cancellation not already requested, set the cancel reason/details and cancel the token source.
public void Cancel(ActivityCancelReason reason)
Parameters
reason
ActivityCancelReasonCancel reason.
Cancel(ActivityCancelReason, ActivityCancellationDetails)
If cancellation not already requested, set the cancel reason/details and cancel the token source.
public void Cancel(ActivityCancelReason reason, ActivityCancellationDetails details)
Parameters
reason
ActivityCancelReasonCancel reason.
details
ActivityCancellationDetailsCancellation details.
RunAsync(Action)
Run the given activity with a context.
public Task RunAsync(Action activity)
Parameters
activity
ActionActivity to run.
Returns
- Task
Task for activity completion.
RunAsync(Func<Task>)
Run the given activity with a context.
public Task RunAsync(Func<Task> activity)
Parameters
Returns
- Task
Task for activity completion.
RunAsync<T>(Func<Task<T>>)
Run the given activity with a context.
public Task<T> RunAsync<T>(Func<Task<T>> activity)
Parameters
Returns
- Task<T>
Activity result.
Type Parameters
T
Return type.
RunAsync<T>(Func<T>)
Run the given activity with a context.
public Task<T> RunAsync<T>(Func<T> activity)
Parameters
activity
Func<T>Activity to run.
Returns
- Task<T>
Activity result.
Type Parameters
T
Return type.