@@ -158,6 +158,45 @@ func (s *ServiceSuite) Test_Setup() {
158
158
err = s .sut .Setup ()
159
159
assert .Nil (s .T (), err )
160
160
161
+ address := s .sut .LocalDevice ().Address ()
162
+ assert .Equal (s .T (), "d:_n:vendor_model-serial" , string (* address ))
163
+
164
+ s .sut .connectionsHub = s .conHub
165
+ s .conHub .EXPECT ().Start ()
166
+ s .sut .Start ()
167
+
168
+ time .Sleep (time .Millisecond * 200 )
169
+
170
+ s .conHub .EXPECT ().Shutdown ()
171
+ s .sut .Shutdown ()
172
+
173
+ device := s .sut .LocalDevice ()
174
+ assert .NotNil (s .T (), device )
175
+ }
176
+
177
+ func (s * ServiceSuite ) Test_Setup_IANA () {
178
+ var err error
179
+ certificate := tls.Certificate {}
180
+ s .config , err = api .NewConfiguration (
181
+ "12345" , "brand" , "model" , "serial" , model .DeviceTypeTypeEnergyManagementSystem ,
182
+ []model.EntityTypeType {model .EntityTypeTypeCEM }, 4729 , certificate , 230.0 , time .Second * 4 )
183
+ assert .Nil (s .T (), nil , err )
184
+
185
+ s .sut = NewService (s .config , s .serviceReader )
186
+
187
+ err = s .sut .Setup ()
188
+ assert .NotNil (s .T (), err )
189
+
190
+ certificate , err = cert .CreateCertificate ("unit" , "org" , "de" , "cn" )
191
+ assert .Nil (s .T (), err )
192
+ s .config .SetCertificate (certificate )
193
+
194
+ err = s .sut .Setup ()
195
+ assert .Nil (s .T (), err )
196
+
197
+ address := s .sut .LocalDevice ().Address ()
198
+ assert .Equal (s .T (), "d:_i:12345_model-serial" , string (* address ))
199
+
161
200
s .sut .connectionsHub = s .conHub
162
201
s .conHub .EXPECT ().Start ()
163
202
s .sut .Start ()
@@ -170,3 +209,28 @@ func (s *ServiceSuite) Test_Setup() {
170
209
device := s .sut .LocalDevice ()
171
210
assert .NotNil (s .T (), device )
172
211
}
212
+
213
+ func (s * ServiceSuite ) Test_Setup_Error_DeviceName () {
214
+ var err error
215
+ certificate := tls.Certificate {}
216
+ s .config , err = api .NewConfiguration (
217
+ "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" ,
218
+ "brand" ,
219
+ "modelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodel" ,
220
+ "serialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserial" ,
221
+ model .DeviceTypeTypeEnergyManagementSystem ,
222
+ []model.EntityTypeType {model .EntityTypeTypeCEM }, 4729 , certificate , 230.0 , time .Second * 4 )
223
+ assert .Nil (s .T (), nil , err )
224
+
225
+ s .sut = NewService (s .config , s .serviceReader )
226
+
227
+ err = s .sut .Setup ()
228
+ assert .NotNil (s .T (), err )
229
+
230
+ certificate , err = cert .CreateCertificate ("unit" , "org" , "de" , "cn" )
231
+ assert .Nil (s .T (), err )
232
+ s .config .SetCertificate (certificate )
233
+
234
+ err = s .sut .Setup ()
235
+ assert .NotNil (s .T (), err )
236
+ }
0 commit comments