WorkflowTest<'Input, 'Result>Type
PackageFCQRS.Workflows
A workflow instance run in memory, for tests. It stores the records the workflow actor would
store, without an actor system or a database. Activities, commands, and child workflows do not
run: the test gives each step's outcome with `Complete` or `Fail`. Time moves only with
`Advance`, which fires timers and signal timeouts. Retry policies are not applied: the outcome a
test gives is the step's final one. Start one with `WorkflowTest.Start`.
Specification
Kind
Type
Members
19
Examples
0
AdvanceSignature
this.Advance
CancelSignature
this.Cancel
CheckReplaySignature
this.CheckReplay
CompleteSignature
this.Complete
FailSignature
this.Fail
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Advance | this.Advance | Moves the time forward, and fires the timers and signal timeouts that are due by then. |
| Cancel | this.Cancel | Cancels the instance: every waiting step fails as `Cancelled`, and the body can run its cleanup. |
| CheckReplay | this.CheckReplay | Restarts the instance after every stored record the test produced, gives it the same outcomes, and checks that each restart stores the same journal. |
| Complete | this.Complete | Completes the waiting activity, command, or child step named `step` with `value`, which is stored and read back as the actor does. |
| Fail | this.Fail | Fails the waiting step named `step` as its retry policy's attempts running out (`Exhausted`). |
| Fail | this.Fail | Fails the waiting activity, command, or child step named `step` with `kind`. |
| Restart | this.Restart | Replays the journal into a new run of the body, as the process does after it stops. |
| Resume | this.Resume | Resumes a faulted instance at the step whose failure faulted it, as `Resume` does for a registered workflow: the body replays its stored steps and that step waits again for the test's outcome. |
| Signal | this.Signal | Stores a signal, as `Workflows.signal` does. |
| StartAgain | this.StartAgain | Starts a new run with `input`, as a start with `WorkflowIdReuse.AfterFailure` does: only when the instance faulted or was cancelled. |
| Summary | this.Summary | One line per stored record, such as `"scheduled 0 price"` or `"completed 0 price"`: the step's path and name. |
| Waiting | this.Waiting | The steps the body waits on, in the order they started. |
| Outcome | this.Outcome | How the instance ended, or `None` while it runs or is parked. |
| Now | this.Now | The time the test runs at. |
| Status | this.Status | Where the instance is, as `Status` reports it for a registered workflow. |
| Id | this.Id | The instance's ID, `test`. |
| Journal | this.Journal | Every record the instance stored, in journal order. |
| Result | this.Result | The body's result. |
| Name | this.Name | The workflow's name. |
Moves the time forward, and fires the timers and signal timeouts that are due by then.
Parameters
| Name | Type | Description |
|---|---|---|
| by | TimeSpan |
Returns
unit
Cancels the instance: every waiting step fails as `Cancelled`, and the body can run its
cleanup. An instance that has ended is left as it is.
Returns
unit
Restarts the instance after every stored record the test produced, gives it the same
outcomes, and checks that each restart stores the same journal. Raises
`WorkflowReplayException` for the first restart that stores a different record or parks the
instance: a body whose steps, stored values, or result change on replay. A pass does not show
that the body is deterministic: an activity's arguments are not stored, so a GUID or a time
read outside a step that reaches only an activity's call is not seen.
Returns
unit
Completes the waiting activity, command, or child step named `step` with `value`, which is
stored and read back as the actor does. A value the step cannot read back fails the step as
`NotRetryable`. Raises `InvalidOperationException` when no such step waits, and
`ArgumentException` when `value` cannot be stored as the step's result.
Parameters
| Name | Type | Description |
|---|---|---|
| step | string | |
| value | 'T |
Returns
unit
Fails the waiting step named `step` as its retry policy's attempts running out
(`Exhausted`).
Parameters
| Name | Type | Description |
|---|---|---|
| step | string | |
| error | exn |
Returns
unit
Fails the waiting activity, command, or child step named `step` with `kind`. A command that
failed as `Exhausted` or `DeadlineExceeded` is stored as `OutcomeUnknown`, as the actor
stores it. The body sees `WorkflowStepFailedException`.
Parameters
| Name | Type | Description |
|---|---|---|
| step | string | |
| error | exn | |
| kind | ErrorKind |
Returns
unit
Replays the journal into a new run of the body, as the process does after it stops. Steps
with a stored outcome are not run again; a step that was waiting waits again.
Returns
unit
Resumes a faulted instance at the step whose failure faulted it, as `Resume` does for a
registered workflow: the body replays its stored steps and that step waits again for the
test's outcome. Raises `InvalidOperationException` with the reason when the instance cannot
resume: it has not faulted, the body threw its own exception, or it ran steps after the
failure.
Returns
unit
Stores a signal, as `Workflows.signal` does. A wait for it takes it, now or when it starts.
Raises `InvalidOperationException` when the instance has ended.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| value | 'T |
Returns
unit
Starts a new run with `input`, as a start with `WorkflowIdReuse.AfterFailure` does: only
when the instance faulted or was cancelled. Otherwise it stores nothing and reports the
instance, as `AlreadyStarted`. The new run replays none of the earlier runs' records.
Parameters
| Name | Type | Description |
|---|---|---|
| input | 'Input |
Returns
StartResult
One line per stored record, such as `"scheduled 0 price"` or `"completed 0 price"`: the
step's path and name. Step values are in `Journal`.
Returns
IReadOnlyList<string>
The steps the body waits on, in the order they started.
Returns
IReadOnlyList<WaitingStep>
How the instance ended, or `None` while it runs or is parked.
Returns
WorkflowOutcome<'Result> option
The time the test runs at. It starts at the time given to `Start` and moves with `Advance`.
Returns
DateTime
Where the instance is, as `Status` reports it for a registered workflow.
Returns
WorkflowStatus
Every record the instance stored, in journal order.
Returns
IReadOnlyList<WorkflowRecord>
The body's result. Raises `WorkflowFaultedException` or `WorkflowCancelledException` when the
instance ended otherwise, and `InvalidOperationException` while it has not ended.
Returns
'Result