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