using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.AdminUI.Uns; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns; [Trait("Category", "Unit")] public sealed class UnsTreeServiceEquipmentChildRowsTests { private static UnsTreeService SeededService() { var dbName = $"uns-childrows-{Guid.NewGuid():N}"; UnsTreeTestDb.SeedNamed(dbName); return new UnsTreeService(UnsTreeTestDb.Factory(dbName)); } [Fact] public async Task LoadTagsForEquipment_returns_tags_in_name_order_scoped() { var rows = await SeededService().LoadTagsForEquipmentAsync(UnsTreeTestDb.SeededEquipmentId); rows.Count.ShouldBe(2); // the EquipmentId=null orphan tag is excluded rows[0].TagId.ShouldBe("TAG-2"); // "running" < "speed" rows[0].Name.ShouldBe("running"); rows[0].DataType.ShouldBe("Boolean"); rows[1].TagId.ShouldBe("TAG-1"); rows[1].DataType.ShouldBe("Float"); } [Fact] public async Task LoadVirtualTagsForEquipment_returns_vtags_in_name_order() { var rows = await SeededService().LoadVirtualTagsForEquipmentAsync(UnsTreeTestDb.SeededEquipmentId); rows.Count.ShouldBe(1); rows[0].VirtualTagId.ShouldBe("VTAG-1"); rows[0].Name.ShouldBe("computed"); rows[0].DataType.ShouldBe("Double"); } [Fact] public async Task LoadTagsForEquipment_empty_for_unknown_equipment() => (await SeededService().LoadTagsForEquipmentAsync("EQ-NONE")).ShouldBeEmpty(); }