@@ -39,11 +39,13 @@ protected override string[] Mappings
3939 get { return new [ ] { "Ado.VerySimple.hbm.xml" , "Ado.AlmostSimple.hbm.xml" } ; }
4040 }
4141
42+ private const int BatchSize = 10 ;
43+
4244 protected override void Configure ( Configuration configuration )
4345 {
4446 configuration . SetProperty ( Environment . FormatSql , "true" ) ;
4547 configuration . SetProperty ( Environment . GenerateStatistics , "true" ) ;
46- configuration . SetProperty ( Environment . BatchSize , "10" ) ;
48+ configuration . SetProperty ( Environment . BatchSize , BatchSize . ToString ( ) ) ;
4749 #if NET6_0_OR_GREATER
4850 if ( _useDbBatch )
4951 {
@@ -287,19 +289,18 @@ public async Task InsertExactlyBatchSizeEntitiesShouldNotThrowOnCommitAsync()
287289 // On commit, ExecuteBatch() is called, sees _batchCommand is set, and calls DoExecuteBatch
288290 // on an empty _currentBatch, causing InvalidOperationException.
289291
290- // BatchSize is configured as 10 in this fixture
291- const int batchSize = 10 ;
292-
293292 using ( var session = OpenSession ( ) )
294293 using ( var transaction = session . BeginTransaction ( ) )
295294 {
296- // Insert exactly BatchSize entities - this fills the batch and triggers auto-execution
297- for ( int i = 0 ; i < batchSize ; i ++ )
295+ // Insert exactly BatchSize entities - this fills the batch and triggers auto-execution.
296+ for ( int i = 0 ; i < BatchSize ; i ++ )
298297 {
299298 await ( session . SaveAsync ( new VerySimple { Id = 1000 + i , Name = $ "Test{ i } ", Weight = i * 1.1 } ) ) ;
300299 }
301300
302- // Commit triggers ExecuteBatch() which would fail on empty batch without the fix
301+ // Commit triggers ExecuteBatch() which would fail on empty batch without the fix,
302+ // depending on the driver. It fails with Microsoft.Data.SqlClient by example, not with
303+ // System.Data.SqlClient.
303304 await ( transaction . CommitAsync ( ) ) ;
304305 }
305306
0 commit comments