Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
419 stars 182 forks source link

Implement test worker/test framework #281

Open fabiocav opened 3 years ago

fabiocav commented 3 years ago

Implement a test worker and test helpers for public consumption.

This should also be adopted by the worker tests in the project.

ciarancolgan commented 3 months ago

How did you define MockBindingContext ?

It's pretty straightforward:

public class MockBindingContext : BindingContext
{
    public MockBindingContext(IReadOnlyDictionary<string, object?> bindingData)
    {
        BindingData = bindingData;
    }

    public override IReadOnlyDictionary<string, object?> BindingData { get; }
}
chullybun commented 1 month ago

To support unit testing, both ASP.NET Web APIs and Azure Functions (including isolated), UnitTestEx was created. This is our attempt to fill this gap and semi-standardize testing implementation - this leverages the WebApplicationFactory for Web APIs and enables a similar capability for Azure Functions including mocking of services etc.

Benjlet commented 2 weeks ago

In case this is of use to others, I have created a basic HttpRequestData builder for .NET 8:

This is based on a few similar issues and respositories, fulfilling some of the simpler use cases for integration/Moq testing.

Anyone is welcome to use/adapt/copy whatever areas may help you.