File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
tests/MongoDB.Driver.Core.Tests Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,11 @@ public TDocument FullDocument
144
144
// if TDocument is BsonDocument avoid deserializing it again to prevent possible duplicate element name errors
145
145
if ( typeof ( TDocument ) == typeof ( BsonDocument ) && BackingDocument . TryGetValue ( "fullDocument" , out var fullDocument ) )
146
146
{
147
+ if ( fullDocument . IsBsonNull )
148
+ {
149
+ return default ;
150
+ }
151
+
147
152
return ( TDocument ) ( object ) fullDocument . AsBsonDocument ;
148
153
}
149
154
else
Original file line number Diff line number Diff line change @@ -323,10 +323,12 @@ public void FullDocument_should_allow_duplicate_elements()
323
323
secondElement . Value . Should ( ) . Be ( 2 ) ;
324
324
}
325
325
326
- [ Fact ]
327
- public void FullDocument_should_return_null_when_not_present ( )
326
+ [ Theory ]
327
+ [ InlineData ( "{ other : 1 }" ) ]
328
+ [ InlineData ( "{ other : 1, fullDocument : null }" ) ]
329
+ public void FullDocument_should_return_null_when_not_present ( string changeDocument )
328
330
{
329
- var backingDocument = new BsonDocument { { "other" , 1 } } ;
331
+ var backingDocument = BsonDocument . Parse ( changeDocument ) ;
330
332
var subject = CreateSubject ( backingDocument : backingDocument ) ;
331
333
332
334
var result = subject . FullDocument ;
You can’t perform that action at this time.
0 commit comments