test(opcua): cover missing-script fallback; rename composer local for clarity
This commit is contained in:
@@ -182,6 +182,34 @@ public sealed class Phase7ComposerPurityTests
|
||||
plan.DependencyRefs.ShouldBe(new[] { "A.X", "B.Y" });
|
||||
}
|
||||
|
||||
/// <summary>A <see cref="VirtualTag"/> whose <c>ScriptId</c> has no matching <see cref="Script"/>
|
||||
/// in the supplied list falls back to an empty Expression and an empty DependencyRefs —
|
||||
/// the plan is always emitted (never dropped) and never carries a null Expression.</summary>
|
||||
[Fact]
|
||||
public void Compose_virtualtag_with_missing_script_yields_empty_expression_and_deps()
|
||||
{
|
||||
var vt = new VirtualTag
|
||||
{
|
||||
VirtualTagId = "vt-missing",
|
||||
EquipmentId = "eq-1",
|
||||
Name = "mystery-tag",
|
||||
DataType = "Float64",
|
||||
ScriptId = "s-does-not-exist",
|
||||
};
|
||||
|
||||
var result = Phase7Composer.Compose(
|
||||
Array.Empty<UnsArea>(), Array.Empty<UnsLine>(), Array.Empty<Equipment>(),
|
||||
Array.Empty<DriverInstance>(), Array.Empty<ScriptedAlarm>(),
|
||||
Array.Empty<Tag>(), Array.Empty<Namespace>(),
|
||||
virtualTags: new[] { vt },
|
||||
scripts: Array.Empty<Script>());
|
||||
|
||||
var plan = result.EquipmentVirtualTags.ShouldHaveSingleItem();
|
||||
plan.VirtualTagId.ShouldBe("vt-missing");
|
||||
plan.Expression.ShouldBe(string.Empty);
|
||||
plan.DependencyRefs.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
private static Equipment NewEquipment(string id) => new()
|
||||
{
|
||||
EquipmentId = id,
|
||||
|
||||
Reference in New Issue
Block a user