11using Microsoft . VisualStudio . TestTools . UnitTesting ;
2- using System . Collections . Generic ;
32using Aml . Engine . CAEX ;
43using Aml . Engine . CAEX . Extensions ;
5- using System . Linq ;
64using System ;
7- using Opc . Ua ;
85
96namespace SystemTest
107{
@@ -26,7 +23,7 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId)
2623
2724 foreach ( AttributeType attribute in objectToTest . Attribute )
2825 {
29- if ( attribute . Name != "NodeId" )
26+ if ( attribute . Name != "NodeId" && attribute . Name != "PracticallyEmpty" )
3027 {
3128 AttributeType structureAttribute = GetAttribute ( attribute , "StructureFieldDefinition" ) ;
3229 foreach ( AttributeType definitionAttribute in structureAttribute . Attribute )
@@ -50,81 +47,82 @@ public void TestUnwantedAttributes(TestHelper.Uris uriId, uint nodeId)
5047 }
5148
5249 [ TestMethod , Timeout ( TestHelper . UnitTestTimeout ) ]
53- [ DataRow ( "QosCategory" , "Name" , "QosCategory ") ]
54- [ DataRow ( "QosCategory" , "Description" , "Quality of Service Category" ) ]
55- [ DataRow ( "QosCategory" , "ValueRank " , "-1 " ) ]
56- [ DataRow ( "QosCategory" , "ArrayDimensions " , null ) ]
57- [ DataRow ( "QosCategory" , "MaxStringLength " , "123 " ) ]
58- [ DataRow ( "QosCategory" , "IsOptional " , "true ") ]
59- [ DataRow ( "QosCategory" , "AllowSubtypes " , "false " ) ]
60-
61- [ DataRow ( "DatagramQos" , "Name" , "DatagramQos" ) ]
62- [ DataRow ( "DatagramQos" , "Description " , "Transmit Quality of Service ") ]
63- [ DataRow ( "DatagramQos" , "ValueRank " , "2 " ) ]
64- [ DataRow ( "DatagramQos" , "MaxStringLength " , "0 " ) ]
65- [ DataRow ( "DatagramQos" , "IsOptional " , "false " ) ]
66- [ DataRow ( "DatagramQos" , "AllowSubtypes " , "true " ) ]
67-
68- [ DataRow ( "NoDescription" , "Name" , "NoDescription" ) ]
69- [ DataRow ( "NoDescription" , "Description " , null ) ]
70- [ DataRow ( "NoDescription" , "ValueRank " , "-1 ") ]
71- [ DataRow ( "NoDescription" , "ArrayDimensions " , null ) ]
72- [ DataRow ( "NoDescription" , "MaxStringLength " , "321 ") ]
73- [ DataRow ( "NoDescription" , "IsOptional " , "false " ) ]
74- [ DataRow ( "NoDescription" , "AllowSubtypes " , "false ") ]
50+ [ DataRow ( "QosCategory" , "Name" , null , "" , " ") ]
51+ [ DataRow ( "QosCategory" , "Description" , "Quality of Service Category" , "0" , "en" ) ]
52+ [ DataRow ( "QosCategory" , "Description " , "Catégorie de qualité de service" , "1" , "fr ") ]
53+ [ DataRow ( "QosCategory" , "Description " , "Kategorie „Dienstqualität“" , "2" , "" ) ]
54+ [ DataRow ( "QosCategory" , "ValueRank " , "-1" , "" , " ") ]
55+ [ DataRow ( "QosCategory" , "ArrayDimensions " , null , "" , " ") ]
56+ [ DataRow ( "QosCategory" , "MaxStringLength " , "123" , "" , " ") ]
57+ [ DataRow ( "QosCategory" , "IsOptional" , "true" , "" , "" ) ]
58+
59+ [ DataRow ( "DatagramQos" , "Name " , null , "" , " ") ]
60+ [ DataRow ( "DatagramQos" , "Description " , "Transmit Quality of Service" , "0" , " ") ]
61+ [ DataRow ( "DatagramQos" , "ArrayDimensions " , "2" , "0" , " ") ]
62+ [ DataRow ( "DatagramQos" , "ArrayDimensions " , "3" , "1" , " ") ]
63+ [ DataRow ( "DatagramQos" , "ValueRank " , "2" , "" , " ") ]
64+ [ DataRow ( "DatagramQos" , "IsOptional" , null , "" , "" ) ]
65+
66+ [ DataRow ( "NoDescription" , "Name " , null , "" , "" ) ]
67+ [ DataRow ( "NoDescription" , "Description " , null , "" , " ") ]
68+ [ DataRow ( "NoDescription" , "ValueRank " , null , "" , "" ) ]
69+ [ DataRow ( "NoDescription" , "ArrayDimensions " , null , "" , " ") ]
70+ [ DataRow ( "NoDescription" , "MaxStringLength " , "321" , "" , " ") ]
71+ [ DataRow ( "NoDescription" , "IsOptional " , null , "" , " ") ]
7572
7673 public void TestAttributeValues ( string variableName ,
7774 string attributeName ,
78- string expectedValue )
79- {
80- AttributeValues ( variableName , attributeName , expectedValue ) ;
81- }
82-
83- [ TestMethod , Timeout ( TestHelper . UnitTestTimeout ) ]
84- public void TestDescriptionLocale ( )
85- {
86- AttributeValues ( "QosCategory" , "Description" , "Quality of Service Category" , "en" ) ;
87- }
88-
89- [ TestMethod , Timeout ( TestHelper . UnitTestTimeout ) ]
90- public void TestArrayDimensions ( )
91- {
92- AttributeType structured = GetStructured ( TestHelper . Uris . Test ,
93- PublisherQosDataType , "DatagramQos" ) ;
94- AttributeType attribute = GetAttribute ( structured , "ArrayDimensions" ) ;
95- AttributeType first = GetAttribute ( attribute , "0" ) ;
96- Assert . AreEqual ( "2" , first . Value , "Unexpected value for ArrayDimensions[0]." ) ;
97- AttributeType second = GetAttribute ( attribute , "1" ) ;
98- Assert . AreEqual ( "3" , second . Value , "Unexpected value for ArrayDimensions[1]." ) ;
99- }
100-
101- public void AttributeValues ( string variableName ,
102- string attributeName ,
10375 string expectedValue ,
104- string localeId = "" )
76+ string arrayIndex ,
77+ string localeId )
10578 {
10679 AttributeFamilyType objectToTest = GetTestAttribute ( TestHelper . Uris . Test ,
10780 PublisherQosDataType ) ;
10881
10982 AttributeType variableAttribute = GetAttribute ( objectToTest . Attribute , variableName ) ;
11083 AttributeType structured = GetAttribute ( variableAttribute , "StructureFieldDefinition" ) ;
111- AttributeType attribute = GetAttribute ( structured . Attribute , attributeName ) ;
112- Assert . AreEqual ( expectedValue , attribute . Value ,
113- $ "Unexpected value for { variableName } .{ attributeName } in { structured . Name } .") ;
11484
115- if ( ! string . IsNullOrEmpty ( localeId ) )
85+ if ( string . IsNullOrEmpty ( expectedValue ) )
86+ {
87+ // attributeName should not exist
88+ Assert . IsNull ( structured . Attribute [ attributeName ] ,
89+ $ "Attribute { attributeName } exists in { variableName } when it should not.") ;
90+ }
91+ else
11692 {
117- AttributeType locale = GetAttribute ( attribute . Attribute , localeId ) ;
118- Assert . AreEqual ( expectedValue , locale . Value ,
119- $ "Unexpected locale value for { variableName } .{ attributeName } in { structured . Name } .") ;
93+ AttributeType attribute = GetAttribute ( structured . Attribute , attributeName ) ;
94+
95+ if ( ! string . IsNullOrEmpty ( arrayIndex ) )
96+ {
97+ attribute = GetAttribute ( attribute , arrayIndex ) ;
98+ }
99+
100+ Assert . AreEqual ( expectedValue , attribute . Value ,
101+ $ "Unexpected value for { variableName } .{ attributeName } in { structured . Name } .") ;
102+
103+ if ( ! string . IsNullOrEmpty ( localeId ) )
104+ {
105+ AttributeType locale = GetAttribute ( attribute . Attribute , localeId ) ;
106+ Assert . AreEqual ( expectedValue , locale . Value ,
107+ $ "Unexpected locale value for { variableName } .{ attributeName } in { structured . Name } .") ;
108+ }
120109 }
121110 }
122111
123112
113+ [ TestMethod , Timeout ( TestHelper . UnitTestTimeout ) ]
114+ public void TestUnwantedStructureAttribute ( )
115+ {
116+ AttributeFamilyType objectToTest = GetTestAttribute ( TestHelper . Uris . Test , PublisherQosDataType ) ;
117+ AttributeType emptyAttribute = GetAttribute ( objectToTest . Attribute , "PracticallyEmpty" ) ;
118+ Assert . IsNull ( emptyAttribute . Attribute [ "StructureFieldDefinition" ] ,
119+ "Unexpected StructureFieldDefinition found in PracticallyEmpty" ) ;
120+ }
121+
124122
125123 #endregion
126124
127- #region Helpers
125+ #region Helpers
128126
129127 private CAEXDocument GetDocument ( )
130128 {
0 commit comments