Skip to content

Commit 1c5237c

Browse files
committed
Reuse SchemaExport in tests
1 parent 03d5aee commit 1c5237c

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
6262
protected override void CreateSchema()
6363
{
6464
var script = new StringBuilder();
65-
new SchemaExport(cfg).Create(sl=> script.Append(sl) , true);
65+
SchemaExport.Create(sl => script.Append(sl), true);
6666
Assert.That(script.ToString(), Does.Not.Contain("LatestMessage"));
6767
}
6868

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task Can_Parameterise_Auxiliary_Database_ObjectsAsync()
4040
{
4141
schemaBuilder = new StringBuilder();
4242

43-
SchemaExport schemaExport = new SchemaExport(cfg);
43+
SchemaExport schemaExport = SchemaExport;
4444
await (schemaExport.ExecuteAsync(AddString, false, false));
4545

4646
string schema = schemaBuilder.ToString();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private void CleanUp()
5050
protected override void CreateSchema()
5151
{
5252
var script = new StringBuilder();
53-
new SchemaExport(cfg).Create(sl=> script.Append(sl) , true);
53+
SchemaExport.Create(sl => script.Append(sl), true);
5454
Assert.That(script.ToString(), Does.Not.Contain("LatestMessage"));
5555
}
5656

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void Can_Parameterise_Auxiliary_Database_Objects()
2929
{
3030
schemaBuilder = new StringBuilder();
3131

32-
SchemaExport schemaExport = new SchemaExport(cfg);
32+
SchemaExport schemaExport = SchemaExport;
3333
schemaExport.Execute(AddString, false, false);
3434

3535
string schema = schemaBuilder.ToString();

src/NHibernate.Test/TestCase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public abstract class TestCase
2222
private const bool OutputDdl = false;
2323
protected Configuration cfg;
2424
private DebugSessionFactory _sessionFactory;
25+
private SchemaExport _schemaExport;
2526

2627
private static readonly ILog log = LogManager.GetLogger(typeof(TestCase));
2728

@@ -48,6 +49,8 @@ protected virtual string MappingsAssembly
4849
get { return "NHibernate.DomainModel"; }
4950
}
5051

52+
protected SchemaExport SchemaExport => _schemaExport ?? (_schemaExport = new SchemaExport(cfg));
53+
5154
static TestCase()
5255
{
5356
// Configure log4net here since configuration through an attribute doesn't always work.
@@ -281,12 +284,12 @@ protected virtual void AddMappings(Configuration configuration)
281284

282285
protected virtual void CreateSchema()
283286
{
284-
new SchemaExport(cfg).Create(OutputDdl, true);
287+
SchemaExport.Create(OutputDdl, true);
285288
}
286289

287290
protected virtual void DropSchema()
288291
{
289-
DropSchema(OutputDdl, new SchemaExport(cfg), Sfi);
292+
DropSchema(OutputDdl, SchemaExport, Sfi);
290293
}
291294

292295
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi)
@@ -315,6 +318,7 @@ private void Cleanup()
315318
Sfi?.Close();
316319
_sessionFactory = null;
317320
cfg = null;
321+
_schemaExport = null;
318322
}
319323

320324
public int ExecuteStatement(string sql)

0 commit comments

Comments
 (0)