Skip to content
In-memory orchestration for testing Durable Functions
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


In-memory orchestration for testing Durable Functions

Build Status


By leveraging DurableOrchestrationClientBase, this project implements InMemoryOrchestrationClient which allows durable functions to be executed in-memory and observed with no mocking. For example, you could write a test such as:

public async Task Can_execute_durable_function()
    var input = new MyFunctionInput();

    var client = new InMemoryOrchestrationClient(typeof(MyFunction).Assembly);
    var instanceId = await client
        .StartNewAsync(nameof(MyFunction.DurableFunction), input);

    await client.WaitForOrchestrationToReachStatus(instanceId, OrchestrationRuntimeStatus.Completed);

    var status = await client.GetStatusAsync(instanceId);

    Assert.AreEqual(OrchestrationRuntimeStatus.Completed, status.RuntimeStatus);

Tests can use the WaitForOrchestrationToReachStatus, WaitForOrchestrationToExpectEvent, RaiseEventAsync and Timeshift methods on the orchestration client to direct the durable function.

Contrast this with the approach suggested in which requires a lot of brittle mocking/setup to accomplish this.

The implementation is currently a proof-of-concept and supports most features of durable functions including activities, retries, sub-orchestrations, external events etc. The major difference is of course that this orchestration client does not have the replay-behavior of durable functions, but simply executes the durable function in-memory with async/await-like behavior.

You can’t perform that action at this time.