@@ -234,11 +234,12 @@ public void Can_deserialize_json_with_underscores()
234
234
}
235
235
}
236
236
237
- public class CustomSerailizerValueTypeTests
237
+ public class CustomSerailizerValueTypeTests
238
238
{
239
- [ Ignore ( "Need to clear static element caches" ) , Test ]
239
+ [ Ignore ( "Needs to clear dirty static element caches from other tests " ) , Test ]
240
240
public void Can_serialize_custom_doubles ( )
241
241
{
242
+ JsConfig < double > . IncludeDefaultValue = true ;
242
243
JsConfig < double > . RawSerializeFn = d =>
243
244
double . IsPositiveInfinity ( d ) ?
244
245
"\" +Inf\" "
@@ -251,6 +252,11 @@ public void Can_serialize_custom_doubles()
251
252
var doubles = new [ ] { 0.0 , 1.0 , double . NegativeInfinity , double . NaN , double . PositiveInfinity } ;
252
253
253
254
Assert . That ( doubles . ToJson ( ) , Is . EqualTo ( "[0,1,\" -Inf\" ,\" NaN\" ,\" +Inf\" ]" ) ) ;
255
+
256
+ Assert . That ( new KeyValuePair < double , double > ( 0 , 1 ) . ToJson ( ) ,
257
+ Is . EqualTo ( "{\" Key\" :0,\" Value\" :1}" ) ) ;
258
+
259
+ JsConfig . Reset ( ) ;
254
260
}
255
261
256
262
public class Model
@@ -261,13 +267,16 @@ public class Model
261
267
[ Test ]
262
268
public void Can_serialize_custom_ints ( )
263
269
{
264
- JsConfig < int > . IncludeDefaultValue = true ;
270
+ // JsConfig<int>.IncludeDefaultValue = true;
265
271
JsConfig < int > . RawSerializeFn = i =>
266
272
i == 0 ? "-1" : i . ToString ( ) ;
267
273
268
274
var dto = new Model { Int = 0 } ;
269
275
270
- Assert . That ( dto . ToJson ( ) , Is . EqualTo ( "{\" Int\" :-1}" ) ) ;
276
+ using ( JsConfig . With ( includeNullValues : true ) )
277
+ {
278
+ Assert . That ( dto . ToJson ( ) , Is . EqualTo ( "{\" Int\" :-1}" ) ) ;
279
+ }
271
280
272
281
JsConfig . Reset ( ) ;
273
282
}
0 commit comments