using Serilog; using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms; using ZB.MOM.WW.OtOpcUa.Core.Scripting; using ZB.MOM.WW.OtOpcUa.Runtime.Drivers; using ZB.MOM.WW.OtOpcUa.Runtime.ScriptedAlarms; namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.ScriptedAlarms; /// /// lmxopcua#779 — the engine the driver host builds for its scripted-alarm host runs predicates on the node's /// Scripting:RunTimeout, not on the 250 ms Phase-7 default it used to fall back to. /// public sealed class ScriptedAlarmEngineBudgetWiringTests { private static readonly ILogger Logger = new LoggerConfiguration().CreateLogger(); [Fact] public void The_host_built_engine_uses_the_configured_RunTimeout() { using var engine = DriverHostActor.CreateScriptedAlarmEngine( new DependencyMuxTagUpstreamSource(), new InMemoryAlarmStateStore(), Logger, new ScriptingOptions { RunTimeout = TimeSpan.FromSeconds(5) }); engine.ScriptTimeout.ShouldBe(TimeSpan.FromSeconds(5)); } [Fact] public void With_no_Scripting_options_the_host_built_engine_gets_the_2s_default_not_250ms() { using var engine = DriverHostActor.CreateScriptedAlarmEngine( new DependencyMuxTagUpstreamSource(), new InMemoryAlarmStateStore(), Logger, scripting: null); engine.ScriptTimeout.ShouldBe(TimeSpan.FromSeconds(2)); engine.ScriptTimeout.ShouldNotBe(TimedScriptEvaluator.DefaultTimeout); } }