File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1188,6 +1188,36 @@ public void TestInsertBatchMultipleBatchesWriteConcernDisabledContinueOnErrorTru
1188
1188
}
1189
1189
}
1190
1190
1191
+ [ Test ]
1192
+ public void TestInsertBatchSmallFinalSubbatch ( )
1193
+ {
1194
+ var collectionName = Configuration . TestCollection . Name ;
1195
+ var collectionSettings = new MongoCollectionSettings { WriteConcern = WriteConcern . Unacknowledged } ;
1196
+ var collection = Configuration . TestDatabase . GetCollection < BsonDocument > ( collectionName , collectionSettings ) ;
1197
+ if ( collection . Exists ( ) ) { collection . Drop ( ) ; }
1198
+
1199
+ using ( Configuration . TestDatabase . RequestStart ( ) )
1200
+ {
1201
+ var maxMessageLength = Configuration . TestServer . RequestConnection . ServerInstance . MaxMessageLength ;
1202
+ var documentCount = maxMessageLength / ( 1024 * 1024 ) + 1 ; // 1 document will overflow to second sub batch
1203
+
1204
+ var documents = new BsonDocument [ documentCount ] ;
1205
+ for ( var i = 0 ; i < documentCount ; i ++ )
1206
+ {
1207
+ var document = new BsonDocument
1208
+ {
1209
+ { "_id" , i } ,
1210
+ { "filler" , new string ( 'x' , 1024 * 1024 ) }
1211
+ } ;
1212
+ documents [ i ] = document ;
1213
+ }
1214
+
1215
+ collection . InsertBatch ( documents ) ;
1216
+
1217
+ Assert . AreEqual ( documentCount , collection . Count ( ) ) ;
1218
+ }
1219
+ }
1220
+
1191
1221
[ Test ]
1192
1222
public void TestIsCappedFalse ( )
1193
1223
{
You can’t perform that action at this time.
0 commit comments