Skip to content

Commit 98a3d82

Browse files
hazzikfredericDelaporte
authored andcommitted
NH-3905 - Fix test failures for Firebird
1 parent 5524fff commit 98a3d82

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using System.Runtime.Serialization.Formatters.Binary;
44
using NHibernate.Cfg;
55
using NHibernate.DomainModel;
6+
using NHibernate.Driver;
7+
using NHibernate.Engine;
68
using NHibernate.Tool.hbm2ddl;
79
using NUnit.Framework;
810

@@ -82,7 +84,8 @@ public void Basic_CRUD_should_work()
8284
var p = session.Get<Parent>(parentId);
8385
Assert.That(p, Is.Null);
8486
}
85-
export.Drop(true, true);
87+
88+
TestCase.DropSchema(true, export, (ISessionFactoryImplementor)sf);
8689
}
8790
}
88-
}
91+
}

src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System.Collections.Generic;
22
using System.Data;
3-
using System.Data.SqlClient;
43
using System.IO;
54
using System.Linq;
65
using System.Reflection;
76
using NHibernate.Cfg;
87
using NHibernate.Connection;
8+
using NHibernate.Engine;
99
using NHibernate.Tool.hbm2ddl;
1010
using NUnit.Framework;
1111

@@ -96,7 +96,8 @@ public void DestroyNorthwindDb()
9696
}
9797
else
9898
{
99-
new SchemaExport(configuration).Drop(false, true);
99+
using (var sf = configuration.BuildSessionFactory())
100+
TestCase.DropSchema(false, new SchemaExport(configuration), (ISessionFactoryImplementor)sf);
100101
}
101102
}
102103

@@ -143,4 +144,4 @@ private void CreateTestData(ISessionFactory sessionFactory)
143144
}
144145
}
145146
}
146-
}
147+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void NotIgnorePrecisionScaleInSchemaExport()
3838
var script = new StringBuilder();
3939
new SchemaExport(cfg).Create(sl => script.AppendLine(sl), true);
4040
Assert.That(script.ToString(), Does.Contain(expectedExportString));
41-
new SchemaExport(cfg).Drop(false, true);
41+
TestCase.DropSchema(false, new SchemaExport(cfg), factory);
4242
}
4343

4444
private Dialect.Dialect GetDialect()

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.Cfg.MappingSchema;
33
using NHibernate.Dialect;
44
using NHibernate.Mapping.ByCode;
5-
using NHibernate.Tool.hbm2ddl;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.NHSpecificTest.NH4004
@@ -45,7 +44,7 @@ protected override bool CheckDatabaseWasCleaned()
4544
[Test]
4645
public void SequenceShallBeDropped()
4746
{
48-
new SchemaExport(cfg).Drop(true, true);
47+
DropSchema();
4948

5049
using (var connection = Sfi.ConnectionProvider.GetConnection())
5150
{
@@ -58,4 +57,4 @@ public void SequenceShallBeDropped()
5857
}
5958
}
6059
}
61-
}
60+
}

src/NHibernate.Test/TestCase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ protected virtual void CreateSchema()
276276

277277
protected virtual void DropSchema()
278278
{
279-
if (Sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
279+
DropSchema(OutputDdl, new SchemaExport(cfg), Sfi);
280+
}
281+
282+
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi)
283+
{
284+
if (sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
280285
{
281286
// Firebird will pool each connection created during the test and will marked as used any table
282287
// referenced by queries. It will at best delays those tables drop until connections are actually
@@ -287,7 +292,7 @@ protected virtual void DropSchema()
287292
fbDriver.ClearPool(null);
288293
}
289294

290-
new SchemaExport(cfg).Drop(OutputDdl, true);
295+
export.Drop(useStdOut, true);
291296
}
292297

293298
protected virtual DebugSessionFactory BuildSessionFactory()

src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void CanWorkWithAutoQuoteTableAndColumnsAtStratup()
248248
t.Commit();
249249
}
250250

251-
new SchemaExport(configuration).Drop(false, false);
251+
TestCase.DropSchema(false, new SchemaExport(configuration), (ISessionFactoryImplementor)sf);
252252
}
253253

254254
[Test]
@@ -285,4 +285,4 @@ public void WhenConfiguredOnlyExplicitAutoQuote()
285285
Assert.That(!GetColumnByName(culs, "Name").IsQuoted);
286286
}
287287
}
288-
}
288+
}

0 commit comments

Comments
 (0)