Skip to content

Commit 0adf1cc

Browse files
authored
Merge pull request #17 from DreamsAndAdventures/my/investigate
Fix Library does not contain EnumValues and ValueAsText
2 parents 6944462 + 7649fe3 commit 0adf1cc

File tree

9 files changed

+68456
-32
lines changed

9 files changed

+68456
-32
lines changed

NodeSetToAML.cs

Lines changed: 248 additions & 31 deletions
Large diffs are not rendered by default.

Opc2Aml.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
</PropertyGroup>
1111

12+
<ItemGroup>
13+
<Compile Remove="SystemTest\**" />
14+
<EmbeddedResource Remove="SystemTest\**" />
15+
<None Remove="SystemTest\**" />
16+
</ItemGroup>
17+
1218
<ItemGroup>
1319
<PackageReference Include="Aml.Engine" Version="2.0.9" />
1420
<PackageReference Include="Aml.Engine.Resources" Version="1.0.1" />

Opc2Aml.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Opc2Aml", "Opc2Aml.csproj", "{19700C18-8B1A-4007-97A1-3FB5FB92770E}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc2Aml", "Opc2Aml.csproj", "{19700C18-8B1A-4007-97A1-3FB5FB92770E}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SystemTest", "SystemTest\SystemTest.csproj", "{B70CE61B-67A0-4B8F-A5E4-D7B68A695BCD}"
79
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
1517
{19700C18-8B1A-4007-97A1-3FB5FB92770E}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{19700C18-8B1A-4007-97A1-3FB5FB92770E}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{19700C18-8B1A-4007-97A1-3FB5FB92770E}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{B70CE61B-67A0-4B8F-A5E4-D7B68A695BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{B70CE61B-67A0-4B8F-A5E4-D7B68A695BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{B70CE61B-67A0-4B8F-A5E4-D7B68A695BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{B70CE61B-67A0-4B8F-A5E4-D7B68A695BCD}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

SystemTest/NodeSetFiles/Opc.Ua.NodeSet2.xml

Lines changed: 66369 additions & 0 deletions
Large diffs are not rendered by default.

SystemTest/NodeSetFiles/TestEnums.xml

Lines changed: 1077 additions & 0 deletions
Large diffs are not rendered by default.

SystemTest/SystemTest.csproj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Aml.Engine" Version="2.0.9" />
12+
<PackageReference Include="Aml.Engine.Resources" Version="1.0.1" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
14+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
15+
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
16+
<PackageReference Include="coverlet.collector" Version="3.1.0" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<None Update="NodeSetFiles\Opc.Ua.NodeSet2.xml">
21+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
22+
</None>
23+
<None Update="NodeSetFiles\TestEnums.xml">
24+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
25+
</None>
26+
<None Update="TestFiles\Opc.Ua.Di.NodeSet2.xml">
27+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
28+
</None>
29+
<None Update="TestFiles\Opc.Ua.NodeSet2.xml">
30+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
31+
</None>
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<Folder Include="NodeSetFiles\" />
36+
</ItemGroup>
37+
38+
</Project>

SystemTest/TestDisplayName.cs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System.IO;
3+
using Aml.Engine.AmlObjects;
4+
using Aml.Engine.CAEX;
5+
using Aml.Engine.CAEX.Extensions;
6+
7+
8+
// Archie - Reverting the DisplayName implementation until the actual issue is addressed
9+
// for example, Ensure that the under the hood aml is understood properly
10+
/*
11+
namespace SystemTest
12+
{
13+
[TestClass]
14+
public class TestDisplayName
15+
{
16+
CAEXDocument m_document = null;
17+
AutomationMLContainer m_container = null;
18+
19+
#region Initialize
20+
21+
[TestInitialize]
22+
public void TestInitialize()
23+
{
24+
if (m_document == null)
25+
{
26+
foreach (FileInfo fileInfo in TestHelper.RetrieveFiles())
27+
{
28+
if (fileInfo.Name.Equals("TestEnums.xml.amlx"))
29+
{
30+
m_container = new AutomationMLContainer(fileInfo.FullName,
31+
System.IO.FileMode.Open, FileAccess.Read);
32+
Assert.IsNotNull(m_container, "Unable to find container");
33+
CAEXDocument document = CAEXDocument.LoadFromStream(m_container.RootDocumentStream());
34+
Assert.IsNotNull(document, "Unable to find document");
35+
m_document = document;
36+
}
37+
}
38+
}
39+
40+
Assert.IsNotNull(m_document, "Unable to retrieve Document");
41+
}
42+
43+
[TestCleanup]
44+
public void TestCleanup()
45+
{
46+
if (m_document != null)
47+
{
48+
m_document.Unload();
49+
}
50+
m_container.Dispose();
51+
52+
}
53+
54+
#endregion
55+
56+
57+
#region Tests
58+
59+
[TestMethod]
60+
[DataRow("5001", "Enumeration Testing", true, DisplayName = "Instance Expected DisplayName")]
61+
[DataRow("5002", "", false, DisplayName = "Instance No DisplayName")]
62+
public void InstanceDisplayName(string nodeId, string expectedDisplayName, bool expectedToBeFound)
63+
{
64+
InternalElementType initialInternalElement = GetObjectToTest(nodeId);
65+
AttributeType displayNameAttribute = initialInternalElement.Attribute["DisplayName"];
66+
if (expectedToBeFound)
67+
{
68+
Assert.IsNotNull(displayNameAttribute, "DisplayName attribute not found");
69+
Assert.AreEqual(expectedDisplayName, displayNameAttribute.Value, "Unexpected value for DisplayName");
70+
}
71+
else
72+
{
73+
Assert.IsNull(displayNameAttribute, "Unexpected attribute found for DisplayName");
74+
}
75+
}
76+
77+
[TestMethod]
78+
[DataRow("1007", "Test Connector Type Display Name", true, DisplayName = "Object Expected DisplayName")]
79+
[DataRow("1000", "", false, DisplayName = "Object No DisplayName")]
80+
public void ObjectDisplayName(string nodeId, string expectedDisplayName, bool expectedToBeFound)
81+
{
82+
SystemUnitFamilyType objectToTest = GetSystemUnitToTest(nodeId);
83+
AttributeType displayNameAttribute = objectToTest.Attribute["DisplayName"];
84+
if (expectedToBeFound)
85+
{
86+
Assert.IsNotNull(displayNameAttribute, "DisplayName attribute not found");
87+
Assert.AreEqual(expectedDisplayName, displayNameAttribute.Value, "Unexpected value for DisplayName");
88+
}
89+
else
90+
{
91+
Assert.IsNull(displayNameAttribute, "Unexpected attribute found for DisplayName");
92+
}
93+
}
94+
95+
#endregion
96+
97+
#region Helpers
98+
99+
private CAEXDocument GetDocument()
100+
{
101+
Assert.IsNotNull(m_document, "Unable to retrieve Document");
102+
return m_document;
103+
}
104+
105+
private CAEXFileType GetFile()
106+
{
107+
CAEXDocument document = GetDocument();
108+
Assert.IsNotNull(document.CAEXFile, "Unable to retrieve File");
109+
return document.CAEXFile;
110+
}
111+
112+
private CAEXSequenceOfCAEXObjects<SystemUnitClassLibType> GetSystemUnitClasses()
113+
{
114+
CAEXFileType file = GetFile();
115+
Assert.IsNotNull(file.SystemUnitClassLib, "Unable to retrieve SystemUnitTypes");
116+
return file.SystemUnitClassLib;
117+
}
118+
119+
private CAEXSequenceOfCAEXObjects<InstanceHierarchyType> GetInstances()
120+
{
121+
CAEXFileType file = GetFile();
122+
Assert.IsNotNull(file.InstanceHierarchy, "Unable to retrieve Instances");
123+
return file.InstanceHierarchy;
124+
}
125+
126+
public InternalElementType GetObjectToTest(string nodeId)
127+
{
128+
CAEXDocument document = GetDocument();
129+
InternalElementType objectToTest = null;
130+
CAEXObject initialObject = document.FindByID(TestHelper.GetRootName() + nodeId);
131+
Assert.IsNotNull(initialObject, "Unable to find Initial Object");
132+
//return initialObject;
133+
InternalElementType initialInternalElement = initialObject as InternalElementType;
134+
Assert.IsNotNull(initialInternalElement, "Unable to find Initial Object");
135+
return initialInternalElement;
136+
}
137+
138+
public SystemUnitFamilyType GetSystemUnitToTest(string nodeId)
139+
{
140+
CAEXDocument document = GetDocument();
141+
InternalElementType objectToTest = null;
142+
CAEXObject initialObject = document.FindByID(TestHelper.GetRootName() + nodeId);
143+
Assert.IsNotNull(initialObject, "Unable to find Initial Object");
144+
SystemUnitFamilyType initialInternalElement = initialObject as SystemUnitFamilyType;
145+
Assert.IsNotNull(initialInternalElement, "Unable to find Initial Object");
146+
return initialInternalElement;
147+
}
148+
149+
#endregion
150+
}
151+
}
152+
*/

0 commit comments

Comments
 (0)