@@ -16,9 +16,18 @@ namespace NHibernate.Test.Ado
16
16
{
17
17
using System . Threading . Tasks ;
18
18
using System . Threading ;
19
- [ TestFixture ]
19
+ #if NET6_0_OR_GREATER
20
+ [ TestFixture ( true ) ]
21
+ #endif
22
+ [ TestFixture ( false ) ]
20
23
public class BatcherFixtureAsync : TestCase
21
24
{
25
+ private readonly bool _useDbBatch ;
26
+
27
+ public BatcherFixtureAsync ( bool useDbBatch )
28
+ {
29
+ _useDbBatch = useDbBatch ;
30
+ }
22
31
protected override string MappingsAssembly
23
32
{
24
33
get { return "NHibernate.Test" ; }
@@ -34,10 +43,22 @@ protected override void Configure(Configuration configuration)
34
43
configuration . SetProperty ( Environment . FormatSql , "true" ) ;
35
44
configuration . SetProperty ( Environment . GenerateStatistics , "true" ) ;
36
45
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
37
52
}
38
53
39
54
protected override bool AppliesTo ( Engine . ISessionFactoryImplementor factory )
40
55
{
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
41
62
return ! ( factory . Settings . BatcherFactory is NonBatchingBatcherFactory ) ;
42
63
}
43
64
@@ -101,20 +122,25 @@ public async Task OneRoundTripUpdateAsync()
101
122
await ( CleanupAsync ( ) ) ;
102
123
}
103
124
104
- [ Test , NetFxOnly ]
125
+ [ Test ]
105
126
[ Description ( "SqlClient: The batcher log output should be formatted" ) ]
106
127
public async Task BatchedoutputShouldBeFormattedAsync ( )
107
128
{
108
129
#if NETFX
109
130
if ( Sfi . Settings . BatcherFactory is SqlClientBatchingBatcherFactory == false )
110
131
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" ) ;
111
137
#endif
112
138
113
139
using ( var sqlLog = new SqlLogSpy ( ) )
114
140
{
115
141
await ( FillDbAsync ( ) ) ;
116
142
var log = sqlLog . GetWholeLog ( ) ;
117
- Assert . IsTrue ( log . Contains ( "INSERT \n INTO" ) ) ;
143
+ Assert . That ( log , Does . Contain ( "INSERT \n INTO" ) . IgnoreCase ) ;
118
144
}
119
145
120
146
await ( CleanupAsync ( ) ) ;
@@ -185,7 +211,7 @@ public async Task AbstractBatcherLogAsync()
185
211
foreach ( var loggingEvent in sl . Appender . GetEvents ( ) )
186
212
{
187
213
string message = loggingEvent . RenderedMessage ;
188
- if ( message . ToLowerInvariant ( ) . Contains ( "insert" ) )
214
+ if ( message . Contains ( "insert" ) )
189
215
{
190
216
Assert . That ( message , Does . Contain ( "batch" ) . IgnoreCase ) ;
191
217
}
0 commit comments