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 may prefer Cancel(ActivityCancelReason) instead.
public ActivityCancelReason CancelReason { 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
WorkerShutdownTokenSource
Gets or inits the worker shutdown token source.
public CancellationTokenSource WorkerShutdownTokenSource { get; init; }
Property Value
Methods
Cancel(ActivityCancelReason)
If cancellation not already requested, set the cancel reason and cancel the token source.
public void Cancel(ActivityCancelReason reason = ActivityCancelReason.CancelRequested)
Parameters
reason
ActivityCancelReasonCancel reason.
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.