513fa1aa16
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.
57 lines
2.7 KiB
C#
57 lines
2.7 KiB
C#
using ZB.MOM.WW.ScadaBridge.Commons.Types.Scripts;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Scripts;
|
|
|
|
/// <summary>Flow Debugger script entry (design 2026-09-08 §2): the monitored attribute of a ValueChange/Conditional trigger.</summary>
|
|
public class ScriptTriggerAttributeTests
|
|
{
|
|
/// <summary>Verifies the case: write Kinds, return The Monitored Attribute.</summary>
|
|
/// <param name="kind">The kind test input.</param>
|
|
/// <param name="config">The config test input.</param>
|
|
/// <param name="expected">The expected test input.</param>
|
|
[Theory]
|
|
[InlineData("ValueChange", """{"attributeName":"Level"}""", "Level")]
|
|
[InlineData("valuechange", """{"attribute":"Level"}""", "Level")]
|
|
[InlineData("Conditional", """{"attributeName":"Level","operator":">","threshold":"5"}""", "Level")]
|
|
[InlineData("CONDITIONAL", """{"attribute":"Flag"}""", "Flag")]
|
|
public void WriteKinds_ReturnTheMonitoredAttribute(string kind, string config, string expected)
|
|
{
|
|
Assert.True(ScriptTriggerAttribute.TryRead(kind, config, out var attribute));
|
|
Assert.Equal(expected, attribute);
|
|
Assert.True(ScriptTriggerAttribute.IsWriteKind(kind));
|
|
}
|
|
|
|
/// <summary>Verifies the case: other Kinds, return False, even When The Config Names An Attribute.</summary>
|
|
/// <param name="kind">The kind test input.</param>
|
|
/// <param name="config">The config test input.</param>
|
|
[Theory]
|
|
[InlineData("Call", """{"attributeName":"Level"}""")]
|
|
[InlineData("Interval", """{"intervalMs":1000}""")]
|
|
[InlineData("Expression", """{"expression":"true"}""")]
|
|
[InlineData(null, null)]
|
|
[InlineData("", "")]
|
|
public void OtherKinds_ReturnFalse_EvenWhenTheConfigNamesAnAttribute(string? kind, string? config)
|
|
{
|
|
Assert.False(ScriptTriggerAttribute.TryRead(kind, config, out var attribute));
|
|
Assert.Null(attribute);
|
|
Assert.False(ScriptTriggerAttribute.IsWriteKind(kind));
|
|
}
|
|
|
|
/// <summary>Verifies the case: write Kind, without AReadable Attribute, returns False, but Is Still AWrite Kind.</summary>
|
|
/// <param name="kind">The kind test input.</param>
|
|
/// <param name="config">The config test input.</param>
|
|
[Theory]
|
|
[InlineData("ValueChange", null)]
|
|
[InlineData("ValueChange", "")]
|
|
[InlineData("ValueChange", "not json")]
|
|
[InlineData("ValueChange", "[1,2]")]
|
|
[InlineData("ValueChange", """{"attributeName":""}""")]
|
|
[InlineData("ValueChange", """{"other":"x"}""")]
|
|
public void WriteKind_WithoutAReadableAttribute_ReturnsFalse_ButIsStillAWriteKind(string kind, string? config)
|
|
{
|
|
Assert.False(ScriptTriggerAttribute.TryRead(kind, config, out var attribute));
|
|
Assert.Null(attribute);
|
|
Assert.True(ScriptTriggerAttribute.IsWriteKind(kind));
|
|
}
|
|
}
|