Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Let AddSiloBuilderConfigurator has an overload which accept an Action to configure cluster #9004

Open
zeinali-ali opened this issue May 16, 2024 · 0 comments

Comments

@zeinali-ali
Copy link

zeinali-ali commented May 16, 2024

Hi
Currently creating a configure class and calling AddSiloBuilderConfigurator<T>() or AddClientBuilderConfigurator<T>() is the only way to configure TestClusterBuilder.

There are cases in which each test may want to just replace a service isolated just for itself, currently we have to create a class for each test which need to setup a fake service:

internal class Test1Configurations : ISiloConfigurator 
{
    internal static MyFakeService fakeService = new();
    void ISiloConfigurator.Configure(ISiloBuilder siloBuilder)
    {
        siloBuilder.Services.AddSingleton<IMyService>(fakeService);
    }
}
[Fact]
public async Task Test1()
{
    _builder.AddSiloBuilderConfigurator<Test1Configurations >();
    var cluster = _builder.Build();
    cluster.Deploy();
    Test1Configurations.fakeService.SetData("test data");
}

It would be so useful if AddSiloBuilderConfigurator and AddClientBuilderConfigurator have an overload like this
void AddSiloBuilderConfigurator(Action<ISiloBuilder> configAction)
the usage would be like this:

[Fact]
public async Task Test1()
{
    var myFakeService = new MyFakeService();
    _builder.AddSiloBuilderConfigurator(siloBuilder =>
    {
        siloBuilder.Services.AddSingleton<IMyService>(myFakeService);
    });
    var cluster = _builder.Build();
    cluster.Deploy();
    myFakeService.SetData("test data");
}

I can prepare a pull request if you agree on this proposal.

@zeinali-ali zeinali-ali changed the title [Proposal] Let AddSiloBuilderConfigurator has a overload which accept an Action to configure cluster [Proposal] Let AddSiloBuilderConfigurator has an overload which accept an Action to configure cluster May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant