Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests/ClusterOptionsTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

85 lines
3.8 KiB
C#

namespace ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests;
/// <summary>
/// Tests for ClusterOptions default values and property setters.
/// </summary>
public class ClusterOptionsTests
{
/// <summary>Verifies that a new options instance carries the expected default values.</summary>
[Fact]
public void DefaultValues_AreCorrect()
{
var options = new ClusterOptions();
// 'auto-down' is the default posture (decision 2026-07-21): a crash of either
// node fails over to the survivor; dual-active during a real partition is the
// accepted trade for pairs with no shared lease infrastructure.
Assert.Equal("auto-down", options.SplitBrainResolverStrategy);
Assert.Equal(TimeSpan.FromSeconds(15), options.StableAfter);
Assert.Equal(TimeSpan.FromSeconds(2), options.HeartbeatInterval);
Assert.Equal(TimeSpan.FromSeconds(10), options.FailureDetectionThreshold);
Assert.Equal(1, options.MinNrOfMembers);
Assert.True(options.DownIfAlone);
}
/// <summary>Verifies that the down-if-alone setting can be changed.</summary>
[Fact]
public void DownIfAlone_CanBeSet()
{
var options = new ClusterOptions { DownIfAlone = false };
Assert.False(options.DownIfAlone);
}
/// <summary>Verifies that the seed node list defaults to an empty list.</summary>
[Fact]
public void SeedNodes_DefaultsToEmptyList()
{
var options = new ClusterOptions();
Assert.NotNull(options.SeedNodes);
Assert.Empty(options.SeedNodes);
}
// The SectionName constant was deleted — the previous test
// `SectionName_IsTheExpectedAppSettingsSection` is removed alongside it.
// The Host's SiteServiceRegistration / StartupValidator continue to
// reference the `"ScadaBridge:Cluster"` literal directly; reinstating the
// constant should happen when those Host binding sites can be updated in
// the same change.
/// <summary>Verifies that the options properties accept custom values.</summary>
[Fact]
public void Properties_CanBeSetToCustomValues()
{
// This test exercises the POCO property setters only —
// `SplitBrainResolverStrategy = "keep-majority"` and `MinNrOfMembers = 2`
// are values the design doc explicitly forbids in production
// (`keep-majority` causes total shutdown on a two-node partition;
// `MinNrOfMembers = 2` blocks the cluster singleton after failover).
// The POCO accepts any value by design; rejection lives in
// `ClusterOptionsValidator` and is covered by
// `ClusterOptionsValidatorTests.UnsupportedSplitBrainStrategy_FailsValidation`
// and `ClusterOptionsValidatorTests.MinNrOfMembers_NotOne_FailsValidation`.
// Do NOT read these values as endorsed runtime configuration.
var options = new ClusterOptions
{
SeedNodes = new List<string> { "akka.tcp://system@node1:2551", "akka.tcp://system@node2:2551" },
SplitBrainResolverStrategy = "keep-majority",
StableAfter = TimeSpan.FromSeconds(30),
HeartbeatInterval = TimeSpan.FromSeconds(5),
FailureDetectionThreshold = TimeSpan.FromSeconds(20),
MinNrOfMembers = 2
};
Assert.Equal(2, options.SeedNodes.Count);
Assert.Contains("akka.tcp://system@node1:2551", options.SeedNodes);
Assert.Contains("akka.tcp://system@node2:2551", options.SeedNodes);
Assert.Equal("keep-majority", options.SplitBrainResolverStrategy);
Assert.Equal(TimeSpan.FromSeconds(30), options.StableAfter);
Assert.Equal(TimeSpan.FromSeconds(5), options.HeartbeatInterval);
Assert.Equal(TimeSpan.FromSeconds(20), options.FailureDetectionThreshold);
Assert.Equal(2, options.MinNrOfMembers);
}
}