@@ -20,11 +20,16 @@ func TestDeviceConfigurationSuite(t *testing.T) {
2020type  DeviceConfigurationSuite  struct  {
2121	suite.Suite 
2222
23- 	localEntity       spineapi.EntityLocalInterface 
24- 	remoteEntity      spineapi.EntityRemoteInterface 
23+ 	localEntity         spineapi.EntityLocalInterface 
24+ 	localEntityPartial  spineapi.EntityLocalInterface 
25+ 
26+ 	remoteEntity         spineapi.EntityRemoteInterface 
27+ 	remoteEntityPartial  spineapi.EntityRemoteInterface 
28+ 
2529	mockRemoteEntity  * mocks.EntityRemoteInterface 
2630
27- 	deviceConfiguration  * DeviceConfiguration 
31+ 	deviceConfiguration         * DeviceConfiguration 
32+ 	deviceConfigurationPartial  * DeviceConfiguration 
2833}
2934
3035const  remoteSki  string  =  "testremoteski" 
@@ -47,6 +52,21 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) {
4752		},
4853	)
4954
55+ 	s .localEntityPartial , s .remoteEntityPartial  =  setupFeatures (
56+ 		s .T (),
57+ 		mockWriter ,
58+ 		[]featureFunctions {
59+ 			{
60+ 				featureType : model .FeatureTypeTypeDeviceConfiguration ,
61+ 				functions : []model.FunctionType {
62+ 					model .FunctionTypeDeviceConfigurationKeyValueDescriptionListData ,
63+ 					model .FunctionTypeDeviceConfigurationKeyValueListData ,
64+ 				},
65+ 				partial : true ,
66+ 			},
67+ 		},
68+ 	)
69+ 
5070	mockRemoteDevice  :=  mocks .NewDeviceRemoteInterface (s .T ())
5171	s .mockRemoteEntity  =  mocks .NewEntityRemoteInterface (s .T ())
5272	mockRemoteFeature  :=  mocks .NewFeatureRemoteInterface (s .T ())
@@ -66,6 +86,10 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) {
6686	s .deviceConfiguration , err  =  NewDeviceConfiguration (s .localEntity , s .remoteEntity )
6787	assert .Nil (s .T (), err )
6888	assert .NotNil (s .T (), s .deviceConfiguration )
89+ 
90+ 	s .deviceConfigurationPartial , err  =  NewDeviceConfiguration (s .localEntityPartial , s .remoteEntityPartial )
91+ 	assert .Nil (s .T (), err )
92+ 	assert .NotNil (s .T (), s .deviceConfiguration )
6993}
7094
7195func  (s  * DeviceConfigurationSuite ) Test_RequestKeyValueDescriptions () {
@@ -104,6 +128,34 @@ func (s *DeviceConfigurationSuite) Test_WriteValues() {
104128	assert .NotNil (s .T (), err )
105129	assert .Nil (s .T (), counter )
106130
131+ 	rF  :=  s .remoteEntity .FeatureOfTypeAndRole (model .FeatureTypeTypeDeviceConfiguration , model .RoleTypeServer )
132+ 	data1  :=  rF .DataCopy (model .FunctionTypeDeviceConfigurationKeyValueListData ).(* model.DeviceConfigurationKeyValueListDataType )
133+ 	assert .Nil (s .T (), data1 )
134+ 
135+ 	defaultData  :=  & model.DeviceConfigurationKeyValueListDataType {
136+ 		DeviceConfigurationKeyValueData : []model.DeviceConfigurationKeyValueDataType {
137+ 			{
138+ 				KeyId :             util .Ptr (model .DeviceConfigurationKeyIdType (0 )),
139+ 				IsValueChangeable : util .Ptr (true ),
140+ 				Value : & model.DeviceConfigurationKeyValueValueType {
141+ 					ScaledNumber : model .NewScaledNumberType (16 ),
142+ 				},
143+ 			},
144+ 			{
145+ 				KeyId :             util .Ptr (model .DeviceConfigurationKeyIdType (1 )),
146+ 				IsValueChangeable : util .Ptr (true ),
147+ 				Value : & model.DeviceConfigurationKeyValueValueType {
148+ 					ScaledNumber : model .NewScaledNumberType (32 ),
149+ 				},
150+ 			},
151+ 		},
152+ 	}
153+ 	_ , err1  :=  rF .UpdateData (true , model .FunctionTypeDeviceConfigurationKeyValueListData , defaultData , nil , nil )
154+ 	assert .Nil (s .T (), err1 )
155+ 	data1  =  rF .DataCopy (model .FunctionTypeDeviceConfigurationKeyValueListData ).(* model.DeviceConfigurationKeyValueListDataType )
156+ 	assert .NotNil (s .T (), data1 )
157+ 	assert .Equal (s .T (), 2 , len (data1 .DeviceConfigurationKeyValueData ))
158+ 
107159	data  =  []model.DeviceConfigurationKeyValueDataType {
108160		{
109161			KeyId : util .Ptr (model .DeviceConfigurationKeyIdType (0 )),
@@ -116,3 +168,55 @@ func (s *DeviceConfigurationSuite) Test_WriteValues() {
116168	assert .Nil (s .T (), err )
117169	assert .NotNil (s .T (), counter )
118170}
171+ 
172+ // test with partial support 
173+ func  (s  * DeviceConfigurationSuite ) Test_WriteValues_Partial () {
174+ 	counter , err  :=  s .deviceConfigurationPartial .WriteKeyValues (nil )
175+ 	assert .NotNil (s .T (), err )
176+ 	assert .Nil (s .T (), counter )
177+ 
178+ 	data  :=  []model.DeviceConfigurationKeyValueDataType {}
179+ 	counter , err  =  s .deviceConfigurationPartial .WriteKeyValues (data )
180+ 	assert .NotNil (s .T (), err )
181+ 	assert .Nil (s .T (), counter )
182+ 
183+ 	rF  :=  s .remoteEntity .FeatureOfTypeAndRole (model .FeatureTypeTypeDeviceConfiguration , model .RoleTypeServer )
184+ 	data1  :=  rF .DataCopy (model .FunctionTypeDeviceConfigurationKeyValueListData ).(* model.DeviceConfigurationKeyValueListDataType )
185+ 	assert .Nil (s .T (), data1 )
186+ 
187+ 	defaultData  :=  & model.DeviceConfigurationKeyValueListDataType {
188+ 		DeviceConfigurationKeyValueData : []model.DeviceConfigurationKeyValueDataType {
189+ 			{
190+ 				KeyId :             util .Ptr (model .DeviceConfigurationKeyIdType (0 )),
191+ 				IsValueChangeable : util .Ptr (true ),
192+ 				Value : & model.DeviceConfigurationKeyValueValueType {
193+ 					ScaledNumber : model .NewScaledNumberType (16 ),
194+ 				},
195+ 			},
196+ 			{
197+ 				KeyId :             util .Ptr (model .DeviceConfigurationKeyIdType (1 )),
198+ 				IsValueChangeable : util .Ptr (true ),
199+ 				Value : & model.DeviceConfigurationKeyValueValueType {
200+ 					ScaledNumber : model .NewScaledNumberType (32 ),
201+ 				},
202+ 			},
203+ 		},
204+ 	}
205+ 	_ , err1  :=  rF .UpdateData (true , model .FunctionTypeDeviceConfigurationKeyValueListData , defaultData , nil , nil )
206+ 	assert .Nil (s .T (), err1 )
207+ 	data1  =  rF .DataCopy (model .FunctionTypeDeviceConfigurationKeyValueListData ).(* model.DeviceConfigurationKeyValueListDataType )
208+ 	assert .NotNil (s .T (), data1 )
209+ 	assert .Equal (s .T (), 2 , len (data1 .DeviceConfigurationKeyValueData ))
210+ 
211+ 	data  =  []model.DeviceConfigurationKeyValueDataType {
212+ 		{
213+ 			KeyId : util .Ptr (model .DeviceConfigurationKeyIdType (0 )),
214+ 			Value : & model.DeviceConfigurationKeyValueValueType {
215+ 				ScaledNumber : model .NewScaledNumberType (10 ),
216+ 			},
217+ 		},
218+ 	}
219+ 	counter , err  =  s .deviceConfigurationPartial .WriteKeyValues (data )
220+ 	assert .Nil (s .T (), err )
221+ 	assert .NotNil (s .T (), counter )
222+ }
0 commit comments