Files
Joseph Doherty 7b0b9c7365 refactor: rename ScadaLink → ZB.MOM.WW.ScadaBridge (code + projects + namespaces)
Solution + 23 src projects + 26 test projects renamed; folders, csproj,
namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated.
ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated.
SQL roles/logins, LDAP domains, CLI command name, and CLI config dir
(~/.scadalink → ~/.scadabridge) also renamed.

Build green; 5 Host.Tests fail awaiting SQL login rename in next commit.
Pre-existing StaleTagMonitor timing flakes unchanged.

Rename script committed at tools/rename-to-scadabridge.sh.
2026-05-28 09:37:45 -04:00

81 lines
3.3 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace ZB.MOM.WW.ScadaBridge.DeploymentManager.Tests;
/// <summary>
/// DeploymentManager-008: DeploymentManagerOptions must be resolvable via the
/// Options pattern and bindable to the "ScadaBridge: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_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?>
{
["ScadaBridge:DeploymentManager:OperationLockTimeout"] = "00:00:09",
["ScadaBridge:DeploymentManager:ArtifactDeploymentTimeoutPerSite"] = "00:03:00"
})
.Build();
var services = new ServiceCollection();
services.Configure<DeploymentManagerOptions>(
configuration.GetSection(ServiceCollectionExtensions.OptionsSection));
services.AddDeploymentManager();
using var provider = services.BuildServiceProvider();
var options = provider.GetRequiredService<IOptions<DeploymentManagerOptions>>().Value;
Assert.Equal(TimeSpan.FromSeconds(9), options.OperationLockTimeout);
Assert.Equal(TimeSpan.FromMinutes(3), options.ArtifactDeploymentTimeoutPerSite);
}
[Fact]
public void OptionsSection_MatchesTheConventionalComponentSectionPath()
{
Assert.Equal("ScadaBridge:DeploymentManager", ServiceCollectionExtensions.OptionsSection);
}
// CentralUI-006: the deployment-status notifier must be a singleton so the
// scoped DeploymentService and the Central UI's scoped Blazor page share
// one instance — without that, a push notification raised by the service
// would never reach the page's subscription.
[Fact]
public void AddDeploymentManager_RegistersDeploymentStatusNotifier_AsSingleton()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddDeploymentManager();
using var provider = services.BuildServiceProvider();
var fromRoot = provider.GetRequiredService<IDeploymentStatusNotifier>();
using var scope = provider.CreateScope();
var fromScope = scope.ServiceProvider.GetRequiredService<IDeploymentStatusNotifier>();
Assert.IsType<DeploymentStatusNotifier>(fromRoot);
Assert.Same(fromRoot, fromScope);
}
}