@@ -441,5 +441,58 @@ public void BinarySet_ToDocument()
441
441
Assert . Equal ( "hello world" , Encoding . UTF8 . GetString ( list [ 0 ] . AsByteArray ( ) ) ) ;
442
442
Assert . Equal ( "hello world!" , Encoding . UTF8 . GetString ( list [ 1 ] . AsByteArray ( ) ) ) ;
443
443
}
444
+
445
+ [ Fact ]
446
+ public void NullAttributes_ToJson ( )
447
+ {
448
+ var evnt = PrepareEvent ( new Dictionary < string , AttributeValue > ( )
449
+ {
450
+ { "Null" , new AttributeValue { NULL = null } } ,
451
+ { "Empty" , new AttributeValue ( ) }
452
+ } ) ;
453
+
454
+ var json = evnt . Records [ 0 ] . Dynamodb . NewImage . ToJson ( ) ;
455
+
456
+ Assert . Equal ( "{\" Null\" :null,\" Empty\" :null}" , json ) ;
457
+ }
458
+
459
+ [ Fact ]
460
+ public void NullAttributes_ToDocument ( )
461
+ {
462
+ var evnt = PrepareEvent ( new Dictionary < string , AttributeValue > ( )
463
+ {
464
+ { "Null" , new AttributeValue { NULL = null } } ,
465
+ { "Empty" , new AttributeValue ( ) }
466
+ } ) ;
467
+
468
+ // Convert the event from the Lambda package to the SDK type
469
+ var json = evnt . Records [ 0 ] . Dynamodb . NewImage . ToJson ( ) ;
470
+ var document = Document . FromJson ( json ) ;
471
+
472
+ Assert . Equal ( DynamoDBNull . Null , document [ "Null" ] . AsDynamoDBNull ( ) ) ;
473
+ Assert . Equal ( DynamoDBNull . Null , document [ "Empty" ] . AsDynamoDBNull ( ) ) ;
474
+ }
475
+
476
+ [ Fact ]
477
+ public void NoAttributes_ToJson ( )
478
+ {
479
+ var evnt = PrepareEvent ( new Dictionary < string , AttributeValue > ( ) ) ;
480
+
481
+ var json = evnt . Records [ 0 ] . Dynamodb . NewImage . ToJson ( ) ;
482
+
483
+ Assert . Equal ( "{}" , json ) ;
484
+ }
485
+
486
+ [ Fact ]
487
+ public void NoAttributes_ToDocument ( )
488
+ {
489
+ var evnt = PrepareEvent ( new Dictionary < string , AttributeValue > ( ) ) ;
490
+
491
+ // Convert the event from the Lambda package to the SDK type
492
+ var json = evnt . Records [ 0 ] . Dynamodb . NewImage . ToJson ( ) ;
493
+ var document = Document . FromJson ( json ) ;
494
+
495
+ Assert . Equal ( 0 , document . Count ) ;
496
+ }
444
497
}
445
498
}
0 commit comments