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
144144 // if TDocument is BsonDocument avoid deserializing it again to prevent possible duplicate element name errors
145145 if ( typeof ( TDocument ) == typeof ( BsonDocument ) && BackingDocument . TryGetValue ( "fullDocument" , out var fullDocument ) )
146146 {
147+ if ( fullDocument . IsBsonNull )
148+ {
149+ return default ;
150+ }
151+
147152 return ( TDocument ) ( object ) fullDocument . AsBsonDocument ;
148153 }
149154 else
Original file line number Diff line number Diff line change @@ -323,10 +323,12 @@ public void FullDocument_should_allow_duplicate_elements()
323323 secondElement . Value . Should ( ) . Be ( 2 ) ;
324324 }
325325
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 )
328330 {
329- var backingDocument = new BsonDocument { { "other" , 1 } } ;
331+ var backingDocument = BsonDocument . Parse ( changeDocument ) ;
330332 var subject = CreateSubject ( backingDocument : backingDocument ) ;
331333
332334 var result = subject . FullDocument ;
You can’t perform that action at this time.
0 commit comments