dotnet / dotnet/orleans

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

Open
#9,004 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
13h 56m
Merged PRs (30d)
351

Description

Hi
Currently creating a configure class and calling `AddSiloBuilderConfigurator()` or `AddClientBuilderConfigurator()` 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(fakeService);
}
}
[Fact]
public async Task Test1()
{
_builder.AddSiloBuilderConfigurator();
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 configAction)`
the usage would be like this:

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

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

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementations of AddSiloBuilderConfigurator and AddClientBuilderConfigurator in the test-cluster builder APIs. Review existing configurator tests, then add coverage showing that an Action or corresponding client action can configure services for an individual test. Done means both overloads support the requested per-test configuration behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.