diff --git a/src/NHibernate.Test/Async/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs index 5244e137e0f..caf304b69ec 100644 --- a/src/NHibernate.Test/Async/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs +++ b/src/NHibernate.Test/Async/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs @@ -38,16 +38,15 @@ protected override DebugSessionFactory BuildSessionFactory() .CollectionTable.Name = "WantedProfessions"; cfg.GetCollectionMapping(typeof (Employee).FullName + ".Secondaries") .CollectionTable.Name = "WantedProfessions"; - return base.BuildSessionFactory(); - } - - protected override void OnTearDown() - { - cfg.GetCollectionMapping(typeof (Employee).FullName + ".Primaries") - .CollectionTable.Name = "WantedProfessions_DUMMY_1"; - cfg.GetCollectionMapping(typeof (Employee).FullName + ".Secondaries") - .CollectionTable.Name = "WantedProfessions_DUMMY_2"; - base.OnTearDown(); + try + { + return base.BuildSessionFactory(); + } + finally + { + // Restore configuration. + Configure(); + } } [Test] diff --git a/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs index db7689f5c6c..edd65f33634 100644 --- a/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs @@ -27,16 +27,15 @@ protected override DebugSessionFactory BuildSessionFactory() .CollectionTable.Name = "WantedProfessions"; cfg.GetCollectionMapping(typeof (Employee).FullName + ".Secondaries") .CollectionTable.Name = "WantedProfessions"; - return base.BuildSessionFactory(); - } - - protected override void OnTearDown() - { - cfg.GetCollectionMapping(typeof (Employee).FullName + ".Primaries") - .CollectionTable.Name = "WantedProfessions_DUMMY_1"; - cfg.GetCollectionMapping(typeof (Employee).FullName + ".Secondaries") - .CollectionTable.Name = "WantedProfessions_DUMMY_2"; - base.OnTearDown(); + try + { + return base.BuildSessionFactory(); + } + finally + { + // Restore configuration. + Configure(); + } } [Test] diff --git a/src/NHibernate.Test/TestCase.cs b/src/NHibernate.Test/TestCase.cs index b8a606ea050..4e4507a6caa 100644 --- a/src/NHibernate.Test/TestCase.cs +++ b/src/NHibernate.Test/TestCase.cs @@ -68,20 +68,12 @@ public void TestFixtureSetUp() Assert.Ignore(GetType() + " does not apply to " + Dialect); } - CreateSchema(); - try + _sessionFactory = BuildSessionFactory(); + if (!AppliesTo(_sessionFactory)) { - _sessionFactory = BuildSessionFactory(); - if (!AppliesTo(_sessionFactory)) - { - Assert.Ignore(GetType() + " does not apply with the current session-factory configuration"); - } - } - catch - { - DropSchema(); - throw; + Assert.Ignore(GetType() + " does not apply with the current session-factory configuration"); } + CreateSchema(); } catch (Exception e) { @@ -116,7 +108,8 @@ public void TestFixtureTearDown() if (!AppliesTo(Dialect)) return; - DropSchema(); + if (AppliesTo(_sessionFactory)) + DropSchema(); Cleanup(); } } @@ -261,7 +254,10 @@ private bool CheckConnectionsWereClosed() return false; } - private void Configure() + /// + /// (Re)Create the configuration. + /// + protected void Configure() { cfg = TestConfigurationHelper.GetDefaultConfiguration();