Skip to content

Commit d566954

Browse files
Restrict a test to SQL-Server.
1 parent 25fc4d3 commit d566954

File tree

2 files changed

+14
-7
lines changed
  • src/NHibernate.Test
    • Async/NHSpecificTest/SqlConverterAndMultiQuery
    • NHSpecificTest/SqlConverterAndMultiQuery

2 files changed

+14
-7
lines changed

src/NHibernate.Test/Async/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
using NHibernate.Cfg;
1212
using NHibernate.Dialect;
13+
using NHibernate.Util;
1314
using NUnit.Framework;
1415

1516
namespace NHibernate.Test.NHSpecificTest.SqlConverterAndMultiQuery
@@ -27,9 +28,12 @@ protected override void Configure(Configuration configuration)
2728

2829
protected override bool AppliesTo(Dialect.Dialect dialect)
2930
{
30-
// MsSqlCe throws InvalidOperationException instead of a DbException for these tests, preventing
31+
// If prepare_sql is enabled, with most databases prepare will fail with an InvalidOperationException,
32+
// turned into ADOException by prepare code and then not passed to the exception converter.
33+
// MsSqlCe throws InvalidOperationException during Prepare (even when disabled), preventing
3134
// the test SqlConverter to do its job.
32-
return !(Dialect is MsSqlCeDialect);
35+
var prepareSql = PropertiesHelper.GetBoolean(Environment.PrepareSql, cfg.Properties, false);
36+
return !(prepareSql || Dialect is MsSqlCeDialect);
3337
}
3438

3539
[Test]

src/NHibernate.Test/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using NHibernate.Cfg;
2-
using NHibernate.Dialect;
2+
using NHibernate.Driver;
3+
using NHibernate.Engine;
34
using NUnit.Framework;
45

56
namespace NHibernate.Test.NHSpecificTest.SqlConverterAndMultiQuery
@@ -14,11 +15,13 @@ protected override void Configure(Configuration configuration)
1415
configuration.DataBaseIntegration(x => x.ExceptionConverter<SqlConverter>());
1516
}
1617

17-
protected override bool AppliesTo(Dialect.Dialect dialect)
18+
protected override bool AppliesTo(ISessionFactoryImplementor factory)
1819
{
19-
// MsSqlCe throws InvalidOperationException instead of a DbException for these tests, preventing
20-
// the test SqlConverter to do its job.
21-
return !(Dialect is MsSqlCeDialect);
20+
// Test current implementation allows to test mmostly SQL Server. Other databases
21+
// tend to (validly) send InvalidOperationException during prepare phase due to the closed
22+
// connection, which get not converted. For testing other case, maybe a failure caused by a
23+
// schema mismatch (like done in transaction tests) would be better.
24+
return factory.ConnectionProvider.Driver is SqlClientDriver;
2225
}
2326

2427
[Test]

0 commit comments

Comments
 (0)