Skip to content

Commit 9013039

Browse files
126 role requirements (#129)
* Update AmlEngine. Problem appears to be isolated to the library * Add Automated tests
1 parent 929c748 commit 9013039

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

Opc2Aml.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Aml.Engine" Version="4.4.0" />
26+
<PackageReference Include="Aml.Engine" Version="4.4.3" />
2727
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.1" />
2828
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.1" />
2929
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />

SystemTest/InternalElements.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,52 @@ public void TestInstanceInternalElements(string[] internalElements, string nodeI
300300
}
301301
}
302302

303+
[TestMethod, Timeout(TestHelper.UnitTestTimeout)]
304+
public void TestInstanceRoleRequirements()
305+
{
306+
var document = GetDocument();
307+
308+
foreach (InstanceHierarchyType instanceHierarchy in document.CAEXFile.InstanceHierarchy)
309+
{
310+
foreach (InternalElementType internalElement in instanceHierarchy.InternalElement)
311+
{
312+
CheckRoleRequirementsRecursive(internalElement);
313+
}
314+
}
315+
}
316+
317+
[TestMethod, Timeout(TestHelper.UnitTestTimeout)]
318+
public void TestRoleRequirements()
319+
{
320+
var document = GetDocument();
321+
322+
foreach (SystemUnitClassLibType libType in document.CAEXFile.SystemUnitClassLib)
323+
{
324+
foreach (SystemUnitClassType systemUnitClass in libType)
325+
{
326+
CheckRoleRequirementsRecursive(systemUnitClass);
327+
}
328+
}
329+
}
330+
331+
private void CheckRoleRequirementsRecursive(SystemUnitClassType entity)
332+
{
333+
var seen = new HashSet<string>();
334+
335+
foreach (IObjectWithRoleReference roleReference in entity.RoleReferences)
336+
{
337+
// Use RefBaseRoleClassPath as the unique key for duplication
338+
string key = roleReference.RoleReference ?? string.Empty;
339+
Assert.IsFalse(seen.Contains(key), $"Duplicate RoleRequirements '{key}' found in '{entity.Name}'");
340+
seen.Add(key);
341+
}
342+
343+
foreach (InternalElementType internalElement in entity.InternalElement)
344+
{
345+
CheckRoleRequirementsRecursive(internalElement);
346+
}
347+
}
348+
303349

304350
#endregion
305351

SystemTest/SystemTest.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Aml.Engine" Version="4.4.0" />
12-
<PackageReference Include="Aml.Engine.Services" Version="4.2.2" />
11+
<PackageReference Include="Aml.Engine" Version="4.4.3" />
12+
<PackageReference Include="Aml.Engine.Services" Version="4.2.4" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1414
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
1515
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />

0 commit comments

Comments
 (0)