fix(host,deployment-manager,communication): repair cross-module DI regressions from batch 1-2
- DeploymentManager-008: revert IConfiguration overload (violated OptionsTests component-convention); Host now binds the ScadaLink:DeploymentManager section - SiteStreamGrpcServer: make test-only int ctor internal so DI sees one public ctor (resolves ambiguous-constructor failure in SiteCompositionRootTests) - Host site composition-root test config: supply Cluster:SeedNodes for the new ClusterOptionsValidator
This commit is contained in:
@@ -5,15 +5,32 @@ using Microsoft.Extensions.Options;
|
||||
namespace ScadaLink.DeploymentManager.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// DeploymentManager-008: DeploymentManagerOptions must be bound to the
|
||||
/// "ScadaLink:DeploymentManager" configuration section, consistent with the
|
||||
/// Options-pattern convention used by the other components.
|
||||
/// DeploymentManager-008: DeploymentManagerOptions must be resolvable via the
|
||||
/// Options pattern and bindable to the "ScadaLink:DeploymentManager"
|
||||
/// configuration section. The component itself does not depend on
|
||||
/// IConfiguration (enforced by Host's OptionsTests) — the Host binds the
|
||||
/// section; AddDeploymentManager only guarantees IOptions resolvability.
|
||||
/// </summary>
|
||||
public class ServiceCollectionExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddDeploymentManager_WithConfiguration_BindsDeploymentManagerOptions()
|
||||
public void AddDeploymentManager_RegistersResolvableOptions_WithDefaults()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddDeploymentManager();
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var options = provider.GetRequiredService<IOptions<DeploymentManagerOptions>>().Value;
|
||||
|
||||
// No section bound -> the option-class defaults are retained.
|
||||
Assert.Equal(TimeSpan.FromSeconds(5), options.OperationLockTimeout);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddDeploymentManager_OptionsBindToConfigurationSection_AsTheHostWires()
|
||||
{
|
||||
// Mirrors the Host wiring: the Host calls Configure<DeploymentManagerOptions>
|
||||
// against OptionsSection, then AddDeploymentManager().
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
@@ -23,7 +40,9 @@ public class ServiceCollectionExtensionsTests
|
||||
.Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddDeploymentManager(configuration);
|
||||
services.Configure<DeploymentManagerOptions>(
|
||||
configuration.GetSection(ServiceCollectionExtensions.OptionsSection));
|
||||
services.AddDeploymentManager();
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var options = provider.GetRequiredService<IOptions<DeploymentManagerOptions>>().Value;
|
||||
@@ -33,17 +52,8 @@ public class ServiceCollectionExtensionsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddDeploymentManager_WithConfiguration_MissingSection_UsesDefaults()
|
||||
public void OptionsSection_MatchesTheConventionalComponentSectionPath()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder().Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddDeploymentManager(configuration);
|
||||
|
||||
using var provider = services.BuildServiceProvider();
|
||||
var options = provider.GetRequiredService<IOptions<DeploymentManagerOptions>>().Value;
|
||||
|
||||
// No section present -> the option-class defaults are retained.
|
||||
Assert.Equal(TimeSpan.FromSeconds(5), options.OperationLockTimeout);
|
||||
Assert.Equal("ScadaLink:DeploymentManager", ServiceCollectionExtensions.OptionsSection);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user