@@ -183,6 +183,23 @@ public void DefaultValueStringKeyClassWithExplicitConstructorTest()
183
183
Assert . Equal ( DefaultValueStringKeyClassWithExplicitConstructor . Prop2Constant , instance . Prop2 ) ;
184
184
}
185
185
186
+ [ Fact ]
187
+ public void DefaultValueStringKeyClassWithExplicitConstructorSetPropertyTest ( )
188
+ {
189
+ var seq = new Sequence < byte > ( ) ;
190
+ var writer = new MessagePackWriter ( seq ) ;
191
+ writer . WriteMapHeader ( 2 ) ;
192
+ writer . Write ( nameof ( DefaultValueStringKeyClassWithExplicitConstructor . Prop1 ) ) ;
193
+ writer . Write ( - 1 ) ;
194
+ writer . Write ( nameof ( DefaultValueStringKeyClassWithExplicitConstructor . Prop2 ) ) ;
195
+ writer . Write ( int . MaxValue ) ;
196
+ writer . Flush ( ) ;
197
+
198
+ var instance = MessagePackSerializer . Deserialize < DefaultValueStringKeyClassWithExplicitConstructor > ( seq ) ;
199
+ Assert . Equal ( - 1 , instance . Prop1 ) ;
200
+ Assert . Equal ( int . MaxValue , instance . Prop2 ) ;
201
+ }
202
+
186
203
[ Fact ]
187
204
public void DefaultValueStringKeyStructWithExplicitConstructorTest ( )
188
205
{
@@ -198,6 +215,23 @@ public void DefaultValueStringKeyStructWithExplicitConstructorTest()
198
215
Assert . Equal ( DefaultValueStringKeyStructWithExplicitConstructor . Prop2Constant , instance . Prop2 ) ;
199
216
}
200
217
218
+ [ Fact ]
219
+ public void DefaultValueStringKeyStructWithExplicitConstructorSetPropertyTest ( )
220
+ {
221
+ var seq = new Sequence < byte > ( ) ;
222
+ var writer = new MessagePackWriter ( seq ) ;
223
+ writer . WriteMapHeader ( 2 ) ;
224
+ writer . Write ( nameof ( DefaultValueStringKeyStructWithExplicitConstructor . Prop1 ) ) ;
225
+ writer . Write ( - 1 ) ;
226
+ writer . Write ( nameof ( DefaultValueStringKeyStructWithExplicitConstructor . Prop2 ) ) ;
227
+ writer . Write ( int . MinValue ) ;
228
+ writer . Flush ( ) ;
229
+
230
+ var instance = MessagePackSerializer . Deserialize < DefaultValueStringKeyStructWithExplicitConstructor > ( seq ) ;
231
+ Assert . Equal ( - 1 , instance . Prop1 ) ;
232
+ Assert . Equal ( int . MinValue , instance . Prop2 ) ;
233
+ }
234
+
201
235
[ Fact ]
202
236
public void DefaultValueIntKeyClassWithoutExplicitConstructorTest ( )
203
237
{
@@ -225,6 +259,21 @@ public void DefaultValueIntKeyClassWithExplicitConstructorTest()
225
259
Assert . Equal ( DefaultValueIntKeyClassWithExplicitConstructor . Prop2Constant , instance . Prop2 ) ;
226
260
}
227
261
262
+ [ Fact ]
263
+ public void DefaultValueIntKeyClassWithExplicitConstructorSetPropertyTest ( )
264
+ {
265
+ var seq = new Sequence < byte > ( ) ;
266
+ var writer = new MessagePackWriter ( seq ) ;
267
+ writer . WriteArrayHeader ( 2 ) ;
268
+ writer . Write ( - 1 ) ;
269
+ writer . Write ( 42 ) ;
270
+ writer . Flush ( ) ;
271
+
272
+ var instance = MessagePackSerializer . Deserialize < DefaultValueIntKeyClassWithExplicitConstructor > ( seq ) ;
273
+ Assert . Equal ( - 1 , instance . Prop1 ) ;
274
+ Assert . Equal ( 42 , instance . Prop2 ) ;
275
+ }
276
+
228
277
[ Fact ]
229
278
public void DefaultValueIntKeyStructWithExplicitConstructorTest ( )
230
279
{
@@ -239,6 +288,21 @@ public void DefaultValueIntKeyStructWithExplicitConstructorTest()
239
288
Assert . Equal ( DefaultValueIntKeyStructWithExplicitConstructor . Prop2Constant , instance . Prop2 ) ;
240
289
}
241
290
291
+ [ Fact ]
292
+ public void DefaultValueIntKeyStructWithExplicitConstructorSetPropertyTest ( )
293
+ {
294
+ var seq = new Sequence < byte > ( ) ;
295
+ var writer = new MessagePackWriter ( seq ) ;
296
+ writer . WriteArrayHeader ( 2 ) ;
297
+ writer . Write ( - 1 ) ;
298
+ writer . Write ( - 98 ) ;
299
+ writer . Flush ( ) ;
300
+
301
+ var instance = MessagePackSerializer . Deserialize < DefaultValueIntKeyStructWithExplicitConstructor > ( seq ) ;
302
+ Assert . Equal ( - 1 , instance . Prop1 ) ;
303
+ Assert . Equal ( - 98 , instance . Prop2 ) ;
304
+ }
305
+
242
306
[ MessagePackObject ( true ) ]
243
307
public class DefaultValueStringKeyClassWithoutExplicitConstructor
244
308
{
0 commit comments