using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Core.Abstractions; using ZB.MOM.WW.OtOpcUa.Driver.AbCip; namespace ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests; /// /// End-to-end smoke tests that exercise the real libplctag stack against a running /// ab_server. Skipped when the binary isn't on PATH (). /// Parametrized over so one test file covers every family /// (ControlLogix / CompactLogix / Micro800 / GuardLogix). /// [Trait("Category", "Integration")] [Trait("Requires", "AbServer")] public sealed class AbCipReadSmokeTests { public static IEnumerable Profiles => KnownProfiles.All.Select(p => new object[] { p }); [AbServerTheory] [MemberData(nameof(Profiles))] public async Task Driver_reads_seeded_DInt_from_ab_server(AbServerProfile profile) { var fixture = new AbServerFixture(profile); await fixture.InitializeAsync(); try { var deviceUri = $"ab://127.0.0.1:{fixture.Port}/1,0"; var drv = new AbCipDriver(new AbCipDriverOptions { Devices = [new AbCipDeviceOptions(deviceUri, profile.Family)], Tags = [new AbCipTagDefinition("Counter", deviceUri, "TestDINT", AbCipDataType.DInt)], Timeout = TimeSpan.FromSeconds(5), }, $"drv-smoke-{profile.Family}"); await drv.InitializeAsync("{}", CancellationToken.None); var snapshots = await drv.ReadAsync(["Counter"], CancellationToken.None); snapshots.Single().StatusCode.ShouldBe(AbCipStatusMapper.Good); drv.GetHealth().State.ShouldBe(DriverState.Healthy); await drv.ShutdownAsync(CancellationToken.None); } finally { await fixture.DisposeAsync(); } } }