Skip to content

Allow function invocation result to be mockable for unit testing #3279

@liliankasem

Description

@liliankasem

Description

Recently in trying to unit test middleware that utlized invocation results, I was not able to directly since interfaces used by that pipeline, such as IFunctionBindingsFeature, are internal. As a result I ended up having to go with an abstraction that is mockable for my unit tests that e.g.

/// <summary>
/// Internal abstraction for accessing function invocation results.
/// This exists as a workaround for IFunctionBindingsFeature being internal in the Worker SDK.
/// </summary>
internal interface IFunctionResultAccessor
{
    /// <summary>
    /// Gets the current invocation result value.
    /// </summary>
    object? GetResult(FunctionContext context);

    /// <summary>
    /// Sets the invocation result value.
    /// </summary>
    void SetResult(FunctionContext context, object? value);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions