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/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 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 @@ - - + +