@@ -20,11 +20,16 @@ func TestDeviceConfigurationSuite(t *testing.T) {
20
20
type DeviceConfigurationSuite struct {
21
21
suite.Suite
22
22
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
+
25
29
mockRemoteEntity * mocks.EntityRemoteInterface
26
30
27
- deviceConfiguration * DeviceConfiguration
31
+ deviceConfiguration * DeviceConfiguration
32
+ deviceConfigurationPartial * DeviceConfiguration
28
33
}
29
34
30
35
const remoteSki string = "testremoteski"
@@ -47,6 +52,21 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) {
47
52
},
48
53
)
49
54
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
+
50
70
mockRemoteDevice := mocks .NewDeviceRemoteInterface (s .T ())
51
71
s .mockRemoteEntity = mocks .NewEntityRemoteInterface (s .T ())
52
72
mockRemoteFeature := mocks .NewFeatureRemoteInterface (s .T ())
@@ -66,6 +86,10 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) {
66
86
s .deviceConfiguration , err = NewDeviceConfiguration (s .localEntity , s .remoteEntity )
67
87
assert .Nil (s .T (), err )
68
88
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 )
69
93
}
70
94
71
95
func (s * DeviceConfigurationSuite ) Test_RequestKeyValueDescriptions () {
@@ -104,6 +128,34 @@ func (s *DeviceConfigurationSuite) Test_WriteValues() {
104
128
assert .NotNil (s .T (), err )
105
129
assert .Nil (s .T (), counter )
106
130
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
+
107
159
data = []model.DeviceConfigurationKeyValueDataType {
108
160
{
109
161
KeyId : util .Ptr (model .DeviceConfigurationKeyIdType (0 )),
@@ -116,3 +168,55 @@ func (s *DeviceConfigurationSuite) Test_WriteValues() {
116
168
assert .Nil (s .T (), err )
117
169
assert .NotNil (s .T (), counter )
118
170
}
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