Extension Model

Alba V5 added a new extension model based on this interface:

/// <summary>
/// Models an extension to an AlbaHost
/// </summary>
public interface IAlbaExtension : IDisposable, IAsyncDisposable
{
    /// <summary>
    /// Called during the initialization of an AlbaHost after the application is started,
    /// so the application DI container is available. Useful for registering setup or teardown
    /// actions on an AlbaHOst
    /// </summary>
    /// <param name="host"></param>
    /// <returns></returns>
    Task Start(IAlbaHost host);
    
    /// <summary>
    /// Allow an extension to alter the application's
    /// IHostBuilder prior to starting the application
    /// </summary>
    /// <param name="builder"></param>
    /// <returns></returns>
    IHostBuilder Configure(IHostBuilder builder);
}

snippet source | anchor

When you are initializing an AlbaHost, you can pass in an optional array of extensions like this sample from the security stub testing:

// This is calling your real web service's configuration
var hostBuilder = WebAppSecuredWithJwt.Program
    .CreateHostBuilder(new string[0]);

// This is a new Alba v5 extension that can "stub" out
// JWT token authentication
var securityStub = new AuthenticationStub()
    .With("foo", "bar")
    .With(JwtRegisteredClaimNames.Email, "guy@company.com")
    .WithName("jeremy");

// AlbaHost was "SystemUnderTest" in previous versions of
// Alba
theHost = new AlbaHost(hostBuilder, securityStub);

snippet source | anchor