From b8cb680739041e81b5d8798eb991be0501250f9f Mon Sep 17 00:00:00 2001 From: Archie Date: Fri, 15 Aug 2025 16:52:39 -0600 Subject: [PATCH 1/2] Update AmlEngine. Problem appears to be isolated to the library Requires Testing --- Opc2Aml.csproj | 2 +- SystemTest/SystemTest.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Opc2Aml.csproj b/Opc2Aml.csproj index bcd36c0..b6836d8 100644 --- a/Opc2Aml.csproj +++ b/Opc2Aml.csproj @@ -23,7 +23,7 @@ - + diff --git a/SystemTest/SystemTest.csproj b/SystemTest/SystemTest.csproj index f61333f..f156f09 100644 --- a/SystemTest/SystemTest.csproj +++ b/SystemTest/SystemTest.csproj @@ -8,8 +8,8 @@ - - + + From b09d1a9e3c9d2c132572aff086902e2d1ad3d3c0 Mon Sep 17 00:00:00 2001 From: Archie Date: Mon, 18 Aug 2025 11:12:07 -0600 Subject: [PATCH 2/2] Add Automated tests --- SystemTest/InternalElements.cs | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/SystemTest/InternalElements.cs b/SystemTest/InternalElements.cs index 556e494..4910ccc 100644 --- a/SystemTest/InternalElements.cs +++ b/SystemTest/InternalElements.cs @@ -300,6 +300,52 @@ public void TestInstanceInternalElements(string[] internalElements, string nodeI } } + [TestMethod, Timeout(TestHelper.UnitTestTimeout)] + public void TestInstanceRoleRequirements() + { + var document = GetDocument(); + + foreach (InstanceHierarchyType instanceHierarchy in document.CAEXFile.InstanceHierarchy) + { + foreach (InternalElementType internalElement in instanceHierarchy.InternalElement) + { + CheckRoleRequirementsRecursive(internalElement); + } + } + } + + [TestMethod, Timeout(TestHelper.UnitTestTimeout)] + public void TestRoleRequirements() + { + var document = GetDocument(); + + foreach (SystemUnitClassLibType libType in document.CAEXFile.SystemUnitClassLib) + { + foreach (SystemUnitClassType systemUnitClass in libType) + { + CheckRoleRequirementsRecursive(systemUnitClass); + } + } + } + + private void CheckRoleRequirementsRecursive(SystemUnitClassType entity) + { + var seen = new HashSet(); + + foreach (IObjectWithRoleReference roleReference in entity.RoleReferences) + { + // Use RefBaseRoleClassPath as the unique key for duplication + string key = roleReference.RoleReference ?? string.Empty; + Assert.IsFalse(seen.Contains(key), $"Duplicate RoleRequirements '{key}' found in '{entity.Name}'"); + seen.Add(key); + } + + foreach (InternalElementType internalElement in entity.InternalElement) + { + CheckRoleRequirementsRecursive(internalElement); + } + } + #endregion