@@ -16,9 +16,18 @@ namespace NHibernate.Test.Ado
1616{
1717 using System . Threading . Tasks ;
1818 using System . Threading ;
19- [ TestFixture ]
19+ #if NET6_0_OR_GREATER
20+ [ TestFixture ( true ) ]
21+ #endif
22+ [ TestFixture ( false ) ]
2023 public class BatcherFixtureAsync : TestCase
2124 {
25+ private readonly bool _useDbBatch ;
26+
27+ public BatcherFixtureAsync ( bool useDbBatch )
28+ {
29+ _useDbBatch = useDbBatch ;
30+ }
2231 protected override string MappingsAssembly
2332 {
2433 get { return "NHibernate.Test" ; }
@@ -34,10 +43,22 @@ protected override void Configure(Configuration configuration)
3443 configuration . SetProperty ( Environment . FormatSql , "true" ) ;
3544 configuration . SetProperty ( Environment . GenerateStatistics , "true" ) ;
3645 configuration . SetProperty ( Environment . BatchSize , "10" ) ;
46+ #if NET6_0_OR_GREATER
47+ if ( _useDbBatch )
48+ {
49+ configuration . SetProperty ( Environment . BatchStrategy , typeof ( DbBatchBatcherFactory ) . AssemblyQualifiedName ) ;
50+ }
51+ #endif
3752 }
3853
3954 protected override bool AppliesTo ( Engine . ISessionFactoryImplementor factory )
4055 {
56+ #if NET6_0_OR_GREATER
57+ if ( _useDbBatch )
58+ {
59+ return factory . Settings . BatcherFactory is DbBatchBatcherFactory && factory . Settings . ConnectionProvider . Driver is Driver . DriverBase driverBase && driverBase . CanCreateBatch ;
60+ }
61+ #endif
4162 return ! ( factory . Settings . BatcherFactory is NonBatchingBatcherFactory ) ;
4263 }
4364
@@ -101,20 +122,25 @@ public async Task OneRoundTripUpdateAsync()
101122 await ( CleanupAsync ( ) ) ;
102123 }
103124
104- [ Test , NetFxOnly ]
125+ [ Test ]
105126 [ Description ( "SqlClient: The batcher log output should be formatted" ) ]
106127 public async Task BatchedoutputShouldBeFormattedAsync ( )
107128 {
108129#if NETFX
109130 if ( Sfi . Settings . BatcherFactory is SqlClientBatchingBatcherFactory == false )
110131 Assert . Ignore ( "This test is for SqlClientBatchingBatcher only" ) ;
132+ #elif NET6_0_OR_GREATER
133+ if ( Sfi . Settings . BatcherFactory is DbBatchBatcherFactory == false )
134+ Assert . Ignore ( "This test is for DbBatchBatcherFactory only" ) ;
135+ #else
136+ Assert . Ignore ( "This test is for NETFX and NET6_0_OR_GREATER only" ) ;
111137#endif
112138
113139 using ( var sqlLog = new SqlLogSpy ( ) )
114140 {
115141 await ( FillDbAsync ( ) ) ;
116142 var log = sqlLog . GetWholeLog ( ) ;
117- Assert . IsTrue ( log . Contains ( "INSERT \n INTO" ) ) ;
143+ Assert . That ( log , Does . Contain ( "INSERT \n INTO" ) . IgnoreCase ) ;
118144 }
119145
120146 await ( CleanupAsync ( ) ) ;
@@ -185,7 +211,7 @@ public async Task AbstractBatcherLogAsync()
185211 foreach ( var loggingEvent in sl . Appender . GetEvents ( ) )
186212 {
187213 string message = loggingEvent . RenderedMessage ;
188- if ( message . ToLowerInvariant ( ) . Contains ( "insert" ) )
214+ if ( message . Contains ( "insert" ) )
189215 {
190216 Assert . That ( message , Does . Contain ( "batch" ) . IgnoreCase ) ;
191217 }
0 commit comments