@@ -637,9 +637,9 @@ public async Task Ensure_generated_ids_are_first_fields_in_document_using_insert
637
637
testCollection . InsertOne ( document ) ;
638
638
}
639
639
640
- eventCapturer . Next ( ) ; // skip the hello command that is captured.
641
- eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandStartedEvent > ( )
642
- . Subject . Command [ "documents" ] [ 0 ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
640
+ var insertEvents = eventCapturer . Events . OfType < CommandStartedEvent > ( ) . Where ( e => e . CommandName == "insert" ) . ToArray ( ) ;
641
+ insertEvents . Length . Should ( ) . Be ( 1 ) ;
642
+ insertEvents [ 0 ] . Command [ "documents" ] [ 0 ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
643
643
document. Names . Should ( ) . Contain ( "_id" ) ;
644
644
}
645
645
@@ -661,9 +661,9 @@ public async Task Ensure_generated_ids_are_first_fields_in_document_using_collec
661
661
testCollection . BulkWrite ( [ new InsertOneModel < BsonDocument > ( document ) ] ) ;
662
662
}
663
663
664
- eventCapturer . Next ( ) ; // skip the hello command that is captured.
665
- eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandStartedEvent > ( )
666
- . Subject . Command [ "documents" ] [ 0 ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
664
+ var insertEvents = eventCapturer . Events . OfType < CommandStartedEvent > ( ) . Where ( e => e . CommandName == "insert" ) . ToArray ( ) ;
665
+ insertEvents . Length . Should ( ) . Be ( 1 ) ;
666
+ insertEvents [ 0 ] . Command [ "documents" ] [ 0 ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
667
667
document. Names . Should ( ) . Contain ( "_id" ) ;
668
668
}
669
669
@@ -686,9 +686,9 @@ public async Task Ensure_generated_ids_are_first_fields_in_document_using_client
686
686
client . BulkWrite ( [ new BulkWriteInsertOneModel < BsonDocument > ( "test.test" , document ) ] ) ;
687
687
}
688
688
689
- eventCapturer . Next ( ) ; // skip the hello command that is captured.
690
- eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandStartedEvent > ( )
691
- . Subject . Command [ "ops" ] [ 0 ] [ "document" ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
689
+ var bulkEvents = eventCapturer . Events . OfType < CommandStartedEvent > ( ) . Where ( e => e . CommandName == "bulkWrite" ) . ToArray ( ) ;
690
+ bulkEvents . Length . Should ( ) . Be ( 1 ) ;
691
+ bulkEvents [ 0 ] . Command [ "ops" ] [ 0 ] [ "document" ] . AsBsonDocument . Names . First ( ) . Should ( ) . Be ( "_id" ) ;
692
692
document. Names . Should ( ) . Contain ( "_id" ) ;
693
693
}
694
694
0 commit comments