Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Deployment/InstanceConfigureMesReportableTests.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

97 lines
4.7 KiB
C#

using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Deployment;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Deployment;
/// <summary>
/// MES reportable (tri-state) on the Instance Configure alarm-override editor.
///
/// <para>The instance-level override is a <c>bool?</c>: null means "inherit the
/// template alarm's <c>IsMesReportable</c>", true/false pin it. The modal surfaces
/// that as a three-option select (Inherited / Reportable / Not reportable).</para>
///
/// <para><c>InstanceConfigure</c> is a heavyweight page (~7 injected services with
/// their own graphs), so — consistent with the rest of this suite's coverage of it
/// (see <c>InstanceConfigureListOverrideTests</c>) — the markup half is a structural
/// assertion over the component source. The half that carries the real risk is the
/// save-time delta rule, which is extracted as a pure helper and pinned directly:
/// the page DELETES the override when it sees no delta, so a reportable-only
/// override would be silently dropped on save if the new term were missing.</para>
/// </summary>
public class InstanceConfigureMesReportableTests
{
private static string DeploymentComponentsRoot
{
get
{
var dir = AppContext.BaseDirectory;
for (var i = 0; i < 6 && dir is not null; i++)
dir = Directory.GetParent(dir)?.FullName;
return Path.Combine(dir!, "src", "ZB.MOM.WW.ScadaBridge.CentralUI",
"Components", "Pages", "Deployment");
}
}
private static string InstanceConfigureMarkup
=> File.ReadAllText(Path.Combine(DeploymentComponentsRoot, "InstanceConfigure.razor"));
/// <summary>Verifies that the override modal has a tri-state MES-reportable select.</summary>
[Fact]
public void OverrideModal_HasTriStateMesReportableSelect()
{
var markup = InstanceConfigureMarkup;
Assert.Contains("data-test=\"alarm-mes-select\"", markup);
// Three options: Inherited (empty value) / Reportable (true) / Not reportable (false).
var selectStart = markup.IndexOf("data-test=\"alarm-mes-select\"", StringComparison.Ordinal);
var selectEnd = markup.IndexOf("</select>", selectStart, StringComparison.Ordinal);
Assert.True(selectEnd > selectStart, "MES reportable select is not closed.");
// Label mirrors the adjacent "Priority override" control.
Assert.Contains("MES reportable override</label>", markup);
var selectBody = markup[selectStart..selectEnd];
var optionCount = selectBody.Split("<option").Length - 1;
Assert.Equal(3, optionCount);
Assert.Contains("value=\"\"", selectBody);
Assert.Contains("value=\"true\"", selectBody);
Assert.Contains("value=\"false\"", selectBody);
}
/// <summary>Verifies that setting only the MES-reportable flag counts as an override delta.</summary>
/// <param name="overrideJson">The override json.</param>
/// <param name="priority">The priority.</param>
/// <param name="mesReportable">The mes reportable.</param>
[Theory]
// The new term: a reportable-only override is a real delta in BOTH directions
// (false is not "no override" — it pins a reportable template alarm off).
[InlineData(null, null, true)]
[InlineData(null, null, false)]
public void HasOverrideDelta_TreatsMesReportableAloneAsADelta(
string? overrideJson, int? priority, bool? mesReportable)
=> Assert.True(InstanceConfigure.HasOverrideDelta(overrideJson, priority, mesReportable));
/// <summary>Verifies that an override with nothing set is not a delta.</summary>
/// <param name="overrideJson">The override json.</param>
/// <param name="priority">The priority.</param>
/// <param name="mesReportable">The mes reportable.</param>
[Theory]
[InlineData(null, null, null)]
[InlineData("", null, null)]
[InlineData(" ", null, null)]
public void HasOverrideDelta_NothingSet_IsNotADelta(
string? overrideJson, int? priority, bool? mesReportable)
=> Assert.False(InstanceConfigure.HasOverrideDelta(overrideJson, priority, mesReportable));
/// <summary>Verifies that the existing override terms still count as a delta.</summary>
/// <param name="overrideJson">The override json.</param>
/// <param name="priority">The priority.</param>
/// <param name="mesReportable">The mes reportable.</param>
[Theory]
[InlineData("{\"hi\":70}", null, null)]
[InlineData(null, 750, null)]
public void HasOverrideDelta_ExistingTermsStillCount(
string? overrideJson, int? priority, bool? mesReportable)
=> Assert.True(InstanceConfigure.HasOverrideDelta(overrideJson, priority, mesReportable));
}