using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.AdminUI.ScriptAnalysis; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.ScriptAnalysis; /// lmxopcua#1056 — the editor refuses a {{equip}} token in a verbatim/raw/interpolated path literal, as the deploy gate does. public sealed class EquipLiteralDiagnosticTests { private static readonly ScriptAnalysisService Svc = new(); [Theory] [InlineData("return ctx.GetTag(@\"{{equip}}/speed\").Value;", null)] [InlineData("return ctx.GetTag(\"\"\"{{equip}}/speed\"\"\").Value;", null)] [InlineData("return ctx.GetTag(@\"{{equip}}/speed\").Value is not null;", ScriptAnalysisModes.AlarmPredicate)] public void A_token_in_a_non_regular_literal_is_an_error_marker_on_its_line(string code, string? mode) { var m = Svc.Diagnose(new DiagnoseRequest("var a = 1;\n" + code, Mode: mode), TestContext.Current.CancellationToken).Markers .Single(x => x.Code == "OTSCRIPT_EQUIPLITERAL"); m.Severity.ShouldBe(8); m.StartLineNumber.ShouldBe(2); m.Message.ShouldContain("regular"); } [Fact] public void The_regular_literal_form_is_not_flagged_positive_control() => Svc.Diagnose(new DiagnoseRequest("return ctx.GetTag(\"{{equip}}/speed\").Value;"), TestContext.Current.CancellationToken).Markers .ShouldNotContain(x => x.Code == "OTSCRIPT_EQUIPLITERAL"); }