diff --git a/src/NHibernate.Test/Ado/BatcherFixture.cs b/src/NHibernate.Test/Ado/BatcherFixture.cs index 835ed5c3f5f..c3ddc1dd8f8 100644 --- a/src/NHibernate.Test/Ado/BatcherFixture.cs +++ b/src/NHibernate.Test/Ado/BatcherFixture.cs @@ -34,16 +34,16 @@ protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) [Description("The batcher should run all INSERT queries in only one roundtrip.")] public void OneRoundTripInserts() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); FillDb(); - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } private void Cleanup() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (s.BeginTransaction()) { s.CreateQuery("delete from VerySimple").ExecuteUpdate(); @@ -54,7 +54,7 @@ private void Cleanup() private void FillDb() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Save(new VerySimple {Id = 1, Name = "Fabio", Weight = 119.5}); @@ -69,20 +69,20 @@ public void OneRoundTripUpdate() { FillDb(); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var vs1 = s.Get(1); var vs2 = s.Get(2); vs1.Weight -= 10; vs2.Weight -= 1; - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s.Update(vs1); s.Update(vs2); tx.Commit(); } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } @@ -90,13 +90,13 @@ public void OneRoundTripUpdate() [Description("SqlClient: The batcher should run all different INSERT queries in only one roundtrip.")] public void SqlClientOneRoundTripForUpdateAndInsert() { - if (sessions.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false) + if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false) Assert.Ignore("This test is for SqlClientBatchingBatcher only"); FillDb(); using(var sqlLog = new SqlLogSpy()) - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Save(new VerySimple @@ -128,7 +128,7 @@ public void SqlClientOneRoundTripForUpdateAndInsert() [Description("SqlClient: The batcher log output should be formatted")] public void BatchedoutputShouldBeFormatted() { - if (sessions.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false) + if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false) Assert.Ignore("This test is for SqlClientBatchingBatcher only"); using (var sqlLog = new SqlLogSpy()) @@ -148,18 +148,18 @@ public void OneRoundTripDelete() { FillDb(); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var vs1 = s.Get(1); var vs2 = s.Get(2); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s.Delete(vs1); s.Delete(vs2); tx.Commit(); } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } @@ -174,7 +174,7 @@ public void SqlLog() { using (var sl = new SqlLogSpy()) { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); Assert.That(logs, Does.Not.Contain("Adding to batch").IgnoreCase); @@ -183,7 +183,7 @@ public void SqlLog() } } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } @@ -198,7 +198,7 @@ public void AbstractBatcherLog() { using (var sl = new SqlLogSpy()) { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); Assert.That(logs, Does.Contain("batch").IgnoreCase); @@ -213,7 +213,7 @@ public void AbstractBatcherLog() } } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } @@ -224,14 +224,14 @@ public void SqlLogShouldGetBatchCommandNotification() { using (var sl = new SqlLogSpy()) { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); Assert.That(logs, Does.Contain("Batch commands:").IgnoreCase); } } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } @@ -244,7 +244,7 @@ public void AbstractBatcherLogFormattedSql() { using (var sl = new SqlLogSpy()) { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); FillDb(); foreach (var loggingEvent in sl.Appender.GetEvents()) { @@ -266,7 +266,7 @@ public void AbstractBatcherLogFormattedSql() } } - Assert.That(sessions.Statistics.PrepareStatementCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.PrepareStatementCount, Is.EqualTo(1)); Cleanup(); } } diff --git a/src/NHibernate.Test/BulkManipulation/BaseFixture.cs b/src/NHibernate.Test/BulkManipulation/BaseFixture.cs index 7ca8dca6970..f72930fec06 100644 --- a/src/NHibernate.Test/BulkManipulation/BaseFixture.cs +++ b/src/NHibernate.Test/BulkManipulation/BaseFixture.cs @@ -33,7 +33,7 @@ protected override void Configure(Cfg.Configuration configuration) public string GetSql(string query) { - var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, sessions).Parse(), emptyfilters, sessions); + var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, Sfi).Parse(), emptyfilters, Sfi); qt.Compile(null, false); return qt.SQLString; } diff --git a/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs b/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs index 0adb65e6b29..c2d1b9d77c8 100644 --- a/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs +++ b/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs @@ -22,13 +22,13 @@ protected override IList Mappings public void ToStringIncludeAll() { string filterName = "DescriptionLike"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionLike{'pLike'='so%'}]")); filterName = "DescriptionEqualAndValueGT"; - f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionEqualAndValueGT{'pDesc'='something', 'pValue'='10'}]")); @@ -49,11 +49,11 @@ public void Equality() private void FilterDescLikeToCompare(out FilterKey fk, out FilterKey fk1) { const string filterName = "DescriptionLike"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); - var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f1 = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f1.SetParameter("pLike", "%ing"); fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); } @@ -61,11 +61,11 @@ private void FilterDescLikeToCompare(out FilterKey fk, out FilterKey fk1) private void FilterDescValueToCompare(out FilterKey fk, out FilterKey fk1) { const string filterName = "DescriptionEqualAndValueGT"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); - var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f1 = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); } diff --git a/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs b/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs index c6ea39b55f3..3a05b77553e 100644 --- a/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs +++ b/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs @@ -38,34 +38,34 @@ public void EqualityWithFilters() private void QueryKeyFilterDescLikeToCompare(out QueryKey qk, out QueryKey qk1) { const string filterName = "DescriptionLike"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; - qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + qk = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); - var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f1 = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f1.SetParameter("pLike", "%ing"); var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk1 }; - qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + qk1 = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); } private void QueryKeyFilterDescValueToCompare(out QueryKey qk, out QueryKey qk1) { const string filterName = "DescriptionEqualAndValueGT"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; - qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + qk = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); - var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f1 = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk1 }; - qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + qk1 = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); } [Test] @@ -109,19 +109,19 @@ public void NotEqualHashCodeWithFilters() public void ToStringWithFilters() { string filterName = "DescriptionLike"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; - var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + var qk = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); Assert.That(qk.ToString(), Does.Contain(string.Format("filters: ['{0}']",fk))); filterName = "DescriptionEqualAndValueGT"; - f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk }; - qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + qk = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); Assert.That(qk.ToString(), Does.Contain(string.Format("filters: ['{0}']", fk))); } @@ -129,17 +129,17 @@ public void ToStringWithFilters() public void ToStringWithMoreFilters() { string filterName = "DescriptionLike"; - var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var f = new FilterImpl(Sfi.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); filterName = "DescriptionEqualAndValueGT"; - var fv = new FilterImpl(sessions.GetFilterDefinition(filterName)); + var fv = new FilterImpl(Sfi.GetFilterDefinition(filterName)); fv.SetParameter("pDesc", "something").SetParameter("pValue", 10); var fvk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk, fvk }; - var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); + var qk = new QueryKey(Sfi, SqlAll, new QueryParameters(), fks, null); Assert.That(qk.ToString(), Does.Contain(string.Format("filters: ['{0}', '{1}']", fk, fvk))); } } diff --git a/src/NHibernate.Test/Cascade/Circle/MultiPathCircleCascadeTest.cs b/src/NHibernate.Test/Cascade/Circle/MultiPathCircleCascadeTest.cs index 66c3e17c19f..bde961403db 100644 --- a/src/NHibernate.Test/Cascade/Circle/MultiPathCircleCascadeTest.cs +++ b/src/NHibernate.Test/Cascade/Circle/MultiPathCircleCascadeTest.cs @@ -424,22 +424,22 @@ protected override void OnTearDown() protected void ClearCounts() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); } protected void AssertInsertCount(long expected) { - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); } protected void AssertUpdateCount(long expected) { - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); } protected void AssertDeleteCount(long expected) { - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Classic/LifecycleFixture.cs b/src/NHibernate.Test/Classic/LifecycleFixture.cs index 91dc1cb7bd5..bf5b2820a4f 100644 --- a/src/NHibernate.Test/Classic/LifecycleFixture.cs +++ b/src/NHibernate.Test/Classic/LifecycleFixture.cs @@ -25,13 +25,13 @@ protected override void Configure(Configuration configuration) [Test] public void Save() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession s = OpenSession()) { s.Save(new EntityWithLifecycle()); s.Flush(); } - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0)); var v = new EntityWithLifecycle("Shinobi", 10, 10); using (ISession s = OpenSession()) @@ -53,14 +53,14 @@ public void Update() } // update detached - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); v.Heigth = 0; using (ISession s = OpenSession()) { s.Update(v); s.Flush(); } - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0)); // cleanup using (ISession s = OpenSession()) @@ -81,13 +81,13 @@ public void Merge() s.Flush(); } v.Heigth = 0; - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession s = OpenSession()) { s.Merge(v); s.Flush(); } - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0)); var v1 = new EntityWithLifecycle("Shinobi", 0, 10); using (ISession s = OpenSession()) @@ -95,8 +95,8 @@ public void Merge() s.Merge(v1); s.Flush(); } - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0)); // cleanup @@ -116,11 +116,11 @@ public void Delete() { s.Save(v); s.Flush(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); v.Heigth = 0; s.Delete(v); s.Flush(); - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(0)); } using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/CollectionTest/IdBagFixture.cs b/src/NHibernate.Test/CollectionTest/IdBagFixture.cs index 8c84c42b59d..c39b46081f9 100644 --- a/src/NHibernate.Test/CollectionTest/IdBagFixture.cs +++ b/src/NHibernate.Test/CollectionTest/IdBagFixture.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); diff --git a/src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.cs b/src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.cs index 51187989458..93bb4a8b3df 100644 --- a/src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.cs +++ b/src/NHibernate.Test/CollectionTest/NullableValueTypeElementMapFixture.cs @@ -19,7 +19,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.Delete("from Parent"); s.Flush(); diff --git a/src/NHibernate.Test/Component/Basic/ComponentTest.cs b/src/NHibernate.Test/Component/Basic/ComponentTest.cs index cbbadffba56..744b9986171 100644 --- a/src/NHibernate.Test/Component/Basic/ComponentTest.cs +++ b/src/NHibernate.Test/Component/Basic/ComponentTest.cs @@ -49,7 +49,7 @@ protected override void Configure(Configuration configuration) protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Delete("from User"); @@ -65,9 +65,9 @@ public void TestUpdateFalse() { User u; - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); @@ -78,10 +78,10 @@ public void TestUpdateFalse() s.Close(); } - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0)); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { u = (User)s.Get(typeof(User), "gavin"); @@ -91,7 +91,7 @@ public void TestUpdateFalse() s.Close(); } - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(1)); } [Test] @@ -99,7 +99,7 @@ public void TestComponent() { User u; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { u = new User("gavin", "secret", new Person("Gavin King", new DateTime(1999, 12, 31), "Karbarook Ave")); @@ -109,7 +109,7 @@ public void TestComponent() t.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { u = (User)s.Get(typeof(User), "gavin"); @@ -120,7 +120,7 @@ public void TestComponent() t.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { u = (User)s.Get(typeof(User), "gavin"); @@ -136,20 +136,20 @@ public void TestComponent() public void TestComponentStateChangeAndDirtiness() { // test for HHH-2366 - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); s.Persist(u); s.Flush(); - long intialUpdateCount = sessions.Statistics.EntityUpdateCount; + long intialUpdateCount = Sfi.Statistics.EntityUpdateCount; u.Person.Address = "Austin"; s.Flush(); - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); - intialUpdateCount = sessions.Statistics.EntityUpdateCount; + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + intialUpdateCount = Sfi.Statistics.EntityUpdateCount; u.Person.Address = "Cedar Park"; s.Flush(); - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(intialUpdateCount + 1)); s.Delete(u); t.Commit(); s.Close(); @@ -163,7 +163,7 @@ public void TestCustomColumnReadAndWrite() const double HEIGHT_INCHES = 73; const double HEIGHT_CENTIMETERS = HEIGHT_INCHES * 2.54d; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { User u = new User("steve", "hibernater", new Person( "Steve Ebersole", new DateTime(1999, 12, 31), "Main St")); @@ -208,7 +208,7 @@ public void TestCustomColumnReadAndWrite() [Ignore("Ported from Hibernate - failing in NH")] public void TestComponentQueries() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { Employee emp = new Employee(); @@ -231,7 +231,7 @@ public void TestComponentQueries() [Test] public void TestComponentFormulaQuery() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.CreateQuery("from User u where u.Person.Yob = 1999").List(); @@ -254,7 +254,7 @@ public void TestComponentFormulaQuery() [Test] public void TestNamedQuery() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.GetNamedQuery("userNameIn") @@ -271,7 +271,7 @@ public void TestMergeComponent() Employee emp = null; IEnumerator enumerator = null; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = new Employee(); @@ -284,7 +284,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -298,7 +298,7 @@ public void TestMergeComponent() emp.OptionalComponent.Value1 = "emp-value1"; emp.OptionalComponent.Value2 = "emp-value2"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Merge(emp); @@ -306,7 +306,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -320,7 +320,7 @@ public void TestMergeComponent() emp.OptionalComponent.Value1 = null; emp.OptionalComponent.Value2 = null; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Merge(emp); @@ -328,7 +328,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -346,7 +346,7 @@ public void TestMergeComponent() emp1.Person.Dob = new DateTime(1999, 12, 31); emp.DirectReports.Add(emp1); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Merge(emp); @@ -354,7 +354,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -374,7 +374,7 @@ public void TestMergeComponent() emp1.OptionalComponent.Value1 = "emp1-value1"; emp1.OptionalComponent.Value2 = "emp1-value2"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Merge(emp); @@ -382,7 +382,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -402,7 +402,7 @@ public void TestMergeComponent() emp1.OptionalComponent.Value1 = null; emp1.OptionalComponent.Value2 = null; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Merge(emp); @@ -410,7 +410,7 @@ public void TestMergeComponent() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { emp = (Employee)s.Get(typeof(Employee), emp.Id); @@ -426,7 +426,7 @@ public void TestMergeComponent() emp1 = (Employee)enumerator.Current; Assert.That(emp1.OptionalComponent, Is.Null); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Delete( emp ); diff --git a/src/NHibernate.Test/Component/Basic/ComponentWithUniqueConstraintTests.cs b/src/NHibernate.Test/Component/Basic/ComponentWithUniqueConstraintTests.cs index 8400d67f786..1a17c6a2826 100644 --- a/src/NHibernate.Test/Component/Basic/ComponentWithUniqueConstraintTests.cs +++ b/src/NHibernate.Test/Component/Basic/ComponentWithUniqueConstraintTests.cs @@ -37,7 +37,7 @@ protected override HbmMapping GetMappings() protected override void OnTearDown() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var transaction = session.BeginTransaction()) { session.Delete("from Employee"); diff --git a/src/NHibernate.Test/CompositeId/ClassWithCompositeIdFixture.cs b/src/NHibernate.Test/CompositeId/ClassWithCompositeIdFixture.cs index 234a6c73f14..a0517d19a5a 100644 --- a/src/NHibernate.Test/CompositeId/ClassWithCompositeIdFixture.cs +++ b/src/NHibernate.Test/CompositeId/ClassWithCompositeIdFixture.cs @@ -39,7 +39,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from ClassWithCompositeId"); s.Flush(); diff --git a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs index 65bbeb00fb9..e2c1b6af8a1 100644 --- a/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs +++ b/src/NHibernate.Test/ConnectionTest/AggressiveReleaseTest.cs @@ -176,8 +176,8 @@ public void SuppliedConnection() { Prepare(); - using (var originalConnection = sessions.ConnectionProvider.GetConnection()) - using (var session = sessions.WithOptions().Connection(originalConnection).OpenSession()) + using (var originalConnection = Sfi.ConnectionProvider.GetConnection()) + using (var session = Sfi.WithOptions().Connection(originalConnection).OpenSession()) { var silly = new Silly("silly"); session.Save(silly); diff --git a/src/NHibernate.Test/ConnectionTest/ThreadLocalCurrentSessionTest.cs b/src/NHibernate.Test/ConnectionTest/ThreadLocalCurrentSessionTest.cs index ca28c12ba4b..1e85954d92c 100644 --- a/src/NHibernate.Test/ConnectionTest/ThreadLocalCurrentSessionTest.cs +++ b/src/NHibernate.Test/ConnectionTest/ThreadLocalCurrentSessionTest.cs @@ -24,9 +24,9 @@ protected override void Configure(Configuration configuration) protected override void Release(ISession session) { - long initialCount = sessions.Statistics.SessionCloseCount; + long initialCount = Sfi.Statistics.SessionCloseCount; session.Transaction.Commit(); - long subsequentCount = sessions.Statistics.SessionCloseCount; + long subsequentCount = Sfi.Statistics.SessionCloseCount; Assert.AreEqual(initialCount + 1, subsequentCount, "Session still open after commit"); // also make sure it was cleaned up from the internal ThreadLocal... Assert.IsFalse(TestableThreadLocalContext.HasBind(), "session still bound to internal ThreadLocal"); @@ -36,7 +36,7 @@ protected override void Release(ISession session) [Test] public void ContextCleanup() { - ISession session = sessions.OpenSession(); + ISession session = Sfi.OpenSession(); session.BeginTransaction(); session.Transaction.Commit(); Assert.IsFalse(session.IsOpen, "session open after txn completion"); diff --git a/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs b/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs index 22aeefc4d76..8238ab4489b 100644 --- a/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs +++ b/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs @@ -2559,17 +2559,17 @@ public void CacheDetachedCriteria() { using (ISession session = OpenSession()) { - bool current = sessions.Statistics.IsStatisticsEnabled; - sessions.Statistics.IsStatisticsEnabled = true; - sessions.Statistics.Clear(); + bool current = Sfi.Statistics.IsStatisticsEnabled; + Sfi.Statistics.IsStatisticsEnabled = true; + Sfi.Statistics.Clear(); DetachedCriteria dc = DetachedCriteria.For(typeof (Student)) .Add(Property.ForName("Name").Eq("Gavin King")) .SetProjection(Property.ForName("StudentNumber")) .SetCacheable(true); - Assert.That(sessions.Statistics.QueryCacheMissCount,Is.EqualTo(0)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryCacheMissCount,Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(0)); dc.GetExecutableCriteria(session).List(); - Assert.That(sessions.Statistics.QueryCacheMissCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCacheMissCount, Is.EqualTo(1)); dc = DetachedCriteria.For(typeof(Student)) .Add(Property.ForName("Name").Eq("Gavin King")) @@ -2577,9 +2577,9 @@ public void CacheDetachedCriteria() .SetCacheable(true); dc.GetExecutableCriteria(session).List(); - Assert.That(sessions.Statistics.QueryCacheMissCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(1)); - sessions.Statistics.IsStatisticsEnabled = false; + Assert.That(Sfi.Statistics.QueryCacheMissCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(1)); + Sfi.Statistics.IsStatisticsEnabled = false; } } diff --git a/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs b/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs index 6e138eff699..9dac8b5ea81 100644 --- a/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs +++ b/src/NHibernate.Test/Criteria/Lambda/IntegrationFixture.cs @@ -340,7 +340,7 @@ public void FunctionsOrder() [Test] public void MultiCriteria() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); @@ -418,7 +418,7 @@ private void SetupPagingData() public void StatelessSession() { int personId; - using (var ss = sessions.OpenStatelessSession()) + using (var ss = Sfi.OpenStatelessSession()) using (var t = ss.BeginTransaction()) { var person = new Person { Name = "test1" }; @@ -427,7 +427,7 @@ public void StatelessSession() t.Commit(); } - using (var ss = sessions.OpenStatelessSession()) + using (var ss = Sfi.OpenStatelessSession()) using (ss.BeginTransaction()) { var statelessPerson1 = ss.QueryOver() diff --git a/src/NHibernate.Test/Criteria/ProjectionsTest.cs b/src/NHibernate.Test/Criteria/ProjectionsTest.cs index 8bc4e71ccc9..19ad48cbbb1 100644 --- a/src/NHibernate.Test/Criteria/ProjectionsTest.cs +++ b/src/NHibernate.Test/Criteria/ProjectionsTest.cs @@ -44,7 +44,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Delete("from System.Object"); session.Flush(); @@ -54,7 +54,7 @@ protected override void OnTearDown() [Test] public void UsingSqlFunctions_Concat() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { string result = session.CreateCriteria(typeof(Student)) .SetProjection(new SqlFunctionProjection("concat", @@ -75,7 +75,7 @@ public void UsingSqlFunctions_Concat_WithCast() { Assert.Ignore("Not supported by the active dialect:{0}.", Dialect); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { string result = session.CreateCriteria(typeof(Student)) .SetProjection(Projections.SqlFunction("concat", @@ -92,7 +92,7 @@ public void UsingSqlFunctions_Concat_WithCast() [Test] public void CanUseParametersWithProjections() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { long result = session.CreateCriteria(typeof(Student)) .SetProjection(new AddNumberProjection("id", 15)) @@ -104,7 +104,7 @@ public void CanUseParametersWithProjections() [Test] public void UsingConditionals() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { string result = session.CreateCriteria(typeof(Student)) .SetProjection( @@ -132,7 +132,7 @@ public void UsingConditionals() [Test] public void UseInWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.In(Projections.Id(), new object[] { 27 })) @@ -145,7 +145,7 @@ public void UseInWithProjection() [Test] public void UseLikeWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Like(Projections.Property("Name"), "aye", MatchMode.Start)) @@ -157,7 +157,7 @@ public void UseLikeWithProjection() [Test] public void UseInsensitiveLikeWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.InsensitiveLike(Projections.Property("Name"), "AYE", MatchMode.Start)) @@ -169,7 +169,7 @@ public void UseInsensitiveLikeWithProjection() [Test] public void UseIdEqWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.IdEq(Projections.Id())) @@ -181,7 +181,7 @@ public void UseIdEqWithProjection() [Test] public void UseEqWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Eq(Projections.Id(), 27L)) @@ -194,7 +194,7 @@ public void UseEqWithProjection() [Test] public void UseGtWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Gt(Projections.Id(), 2L)) @@ -206,7 +206,7 @@ public void UseGtWithProjection() [Test] public void UseLtWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Lt(Projections.Id(), 200L)) @@ -218,7 +218,7 @@ public void UseLtWithProjection() [Test] public void UseLeWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Le(Projections.Id(), 27L)) @@ -230,7 +230,7 @@ public void UseLeWithProjection() [Test] public void UseGeWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Ge(Projections.Id(), 27L)) @@ -242,7 +242,7 @@ public void UseGeWithProjection() [Test] public void UseBetweenWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.Between(Projections.Id(), 10L, 28L)) @@ -254,7 +254,7 @@ public void UseBetweenWithProjection() [Test] public void UseIsNullWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.IsNull(Projections.Id())) @@ -266,7 +266,7 @@ public void UseIsNullWithProjection() [Test] public void UseIsNotNullWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.IsNotNull(Projections.Id())) @@ -278,7 +278,7 @@ public void UseIsNotNullWithProjection() [Test] public void UseEqPropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.EqProperty(Projections.Id(), Projections.Id())) @@ -290,7 +290,7 @@ public void UseEqPropertyWithProjection() [Test] public void UseGePropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.GeProperty(Projections.Id(), Projections.Id())) @@ -302,7 +302,7 @@ public void UseGePropertyWithProjection() [Test] public void UseGtPropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.GtProperty(Projections.Id(), Projections.Id())) @@ -314,7 +314,7 @@ public void UseGtPropertyWithProjection() [Test] public void UseLtPropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.LtProperty(Projections.Id(), Projections.Id())) @@ -326,7 +326,7 @@ public void UseLtPropertyWithProjection() [Test] public void UseLePropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.LeProperty(Projections.Id(), Projections.Id())) @@ -338,7 +338,7 @@ public void UseLePropertyWithProjection() [Test] public void UseNotEqPropertyWithProjection() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { IList list = session.CreateCriteria(typeof(Student)) .Add(Expression.NotEqProperty("id", Projections.Id())) diff --git a/src/NHibernate.Test/DebugSessionFactory.cs b/src/NHibernate.Test/DebugSessionFactory.cs new file mode 100644 index 00000000000..f94d440b21e --- /dev/null +++ b/src/NHibernate.Test/DebugSessionFactory.cs @@ -0,0 +1,474 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data.Common; +using System.Threading; +using log4net; +using NHibernate.Cache; +using NHibernate.Cfg; +using NHibernate.Connection; +using NHibernate.Context; +using NHibernate.Dialect.Function; +using NHibernate.Engine; +using NHibernate.Engine.Query; +using NHibernate.Event; +using NHibernate.Exceptions; +using NHibernate.Id; +using NHibernate.Impl; +using NHibernate.Metadata; +using NHibernate.Persister.Collection; +using NHibernate.Persister.Entity; +using NHibernate.Proxy; +using NHibernate.Stat; +using NHibernate.Transaction; +using NHibernate.Type; + +namespace NHibernate.Test +{ + /// + /// This session factory keeps a list of all opened sessions, + /// it is used when testing to check that tests clean up after themselves. + /// + /// Sessions opened from other sessions are not tracked. + public class DebugSessionFactory : ISessionFactoryImplementor + { + public DebugConnectionProvider ConnectionProvider { get; } + public ISessionFactoryImplementor ActualFactory { get; } + + public EventListeners EventListeners => ((SessionFactoryImpl)ActualFactory).EventListeners; + + private readonly ConcurrentBag _openedSessions = new ConcurrentBag(); + private static readonly ILog _log = LogManager.GetLogger(typeof(DebugSessionFactory).Assembly, typeof(TestCase)); + + public DebugSessionFactory(ISessionFactory actualFactory) + { + ActualFactory = (ISessionFactoryImplementor)actualFactory; + ConnectionProvider = ActualFactory.ConnectionProvider as DebugConnectionProvider; + } + + #region Session tracking + + public bool CheckSessionsWereClosed() + { + var allClosed = true; + foreach (var session in _openedSessions) + { + if (session.IsOpen) + { + if (session.TransactionContext?.ShouldCloseSessionOnDistributedTransactionCompleted ?? false) + { + // Delayed transactions not having completed and closed their sessions? Give them a chance to complete. + Thread.Sleep(100); + if (!session.IsOpen) + { + _log.Warn($"Test case had a delayed close of session {session.SessionId}."); + continue; + } + } + + _log.Error($"Test case didn't close session {session.SessionId}, closing"); + allClosed = false; + (session as ISession)?.Close(); + (session as IStatelessSession)?.Close(); + } + } + + return allClosed; + } + + ISessionBuilder ISessionFactory.WithOptions() + { + return new SessionBuilder(ActualFactory.WithOptions(), this); + } + + ISession ISessionFactory.OpenSession(DbConnection connection) + { +#pragma warning disable CS0618 // Type or member is obsolete + var s = ActualFactory.OpenSession(connection); +#pragma warning restore CS0618 // Type or member is obsolete + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + ISession ISessionFactory.OpenSession(IInterceptor sessionLocalInterceptor) + { +#pragma warning disable CS0618 // Type or member is obsolete + var s = ActualFactory.OpenSession(sessionLocalInterceptor); +#pragma warning restore CS0618 // Type or member is obsolete + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + ISession ISessionFactory.OpenSession(DbConnection conn, IInterceptor sessionLocalInterceptor) + { +#pragma warning disable CS0618 // Type or member is obsolete + var s = ActualFactory.OpenSession(conn, sessionLocalInterceptor); +#pragma warning restore CS0618 // Type or member is obsolete + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + ISession ISessionFactory.OpenSession() + { + var s = ActualFactory.OpenSession(); + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + IStatelessSessionBuilder ISessionFactory.WithStatelessOptions() + { + return new StatelessSessionBuilder(ActualFactory.WithStatelessOptions(), this); + } + + IStatelessSession ISessionFactory.OpenStatelessSession() + { + var s = ActualFactory.OpenStatelessSession(); + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + IStatelessSession ISessionFactory.OpenStatelessSession(DbConnection connection) + { + var s = ActualFactory.OpenStatelessSession(connection); + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + ISession ISessionFactoryImplementor.OpenSession( + DbConnection connection, + bool flushBeforeCompletionEnabled, + bool autoCloseSessionEnabled, + ConnectionReleaseMode connectionReleaseMode) + { + var s = ActualFactory.OpenSession(connection, flushBeforeCompletionEnabled, autoCloseSessionEnabled, connectionReleaseMode); + _openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + #endregion + + #region Delegated calls without any changes + + IType IMapping.GetIdentifierType(string className) + { + return ActualFactory.GetIdentifierType(className); + } + + string IMapping.GetIdentifierPropertyName(string className) + { + return ActualFactory.GetIdentifierPropertyName(className); + } + + IType IMapping.GetReferencedPropertyType(string className, string propertyName) + { + return ActualFactory.GetReferencedPropertyType(className, propertyName); + } + + bool IMapping.HasNonIdentifierPropertyNamedId(string className) + { + return ActualFactory.HasNonIdentifierPropertyNamedId(className); + } + + void IDisposable.Dispose() + { + ActualFactory.Dispose(); + } + + IClassMetadata ISessionFactory.GetClassMetadata(System.Type persistentClass) + { + return ActualFactory.GetClassMetadata(persistentClass); + } + + IClassMetadata ISessionFactory.GetClassMetadata(string entityName) + { + return ActualFactory.GetClassMetadata(entityName); + } + + ICollectionMetadata ISessionFactory.GetCollectionMetadata(string roleName) + { + return ActualFactory.GetCollectionMetadata(roleName); + } + + IDictionary ISessionFactory.GetAllClassMetadata() + { + return ActualFactory.GetAllClassMetadata(); + } + + IDictionary ISessionFactory.GetAllCollectionMetadata() + { + return ActualFactory.GetAllCollectionMetadata(); + } + + void ISessionFactory.Close() + { + ActualFactory.Close(); + } + + void ISessionFactory.Evict(System.Type persistentClass) + { + ActualFactory.Evict(persistentClass); + } + + void ISessionFactory.Evict(System.Type persistentClass, object id) + { + ActualFactory.Evict(persistentClass, id); + } + + void ISessionFactory.EvictEntity(string entityName) + { + ActualFactory.EvictEntity(entityName); + } + + void ISessionFactory.EvictEntity(string entityName, object id) + { + ActualFactory.EvictEntity(entityName, id); + } + + void ISessionFactory.EvictCollection(string roleName) + { + ActualFactory.EvictCollection(roleName); + } + + void ISessionFactory.EvictCollection(string roleName, object id) + { + ActualFactory.EvictCollection(roleName, id); + } + + void ISessionFactory.EvictQueries() + { + ActualFactory.EvictQueries(); + } + + void ISessionFactory.EvictQueries(string cacheRegion) + { + ActualFactory.EvictQueries(cacheRegion); + } + + FilterDefinition ISessionFactory.GetFilterDefinition(string filterName) + { + return ActualFactory.GetFilterDefinition(filterName); + } + + ISession ISessionFactory.GetCurrentSession() + { + return ActualFactory.GetCurrentSession(); + } + + IStatistics ISessionFactory.Statistics => ActualFactory.Statistics; + + bool ISessionFactory.IsClosed => ActualFactory.IsClosed; + + ICollection ISessionFactory.DefinedFilterNames => ActualFactory.DefinedFilterNames; + + Dialect.Dialect ISessionFactoryImplementor.Dialect => ActualFactory.Dialect; + + IInterceptor ISessionFactoryImplementor.Interceptor => ActualFactory.Interceptor; + + QueryPlanCache ISessionFactoryImplementor.QueryPlanCache => ActualFactory.QueryPlanCache; + + IConnectionProvider ISessionFactoryImplementor.ConnectionProvider => ActualFactory.ConnectionProvider; + + ITransactionFactory ISessionFactoryImplementor.TransactionFactory => ActualFactory.TransactionFactory; + + UpdateTimestampsCache ISessionFactoryImplementor.UpdateTimestampsCache => ActualFactory.UpdateTimestampsCache; + + IStatisticsImplementor ISessionFactoryImplementor.StatisticsImplementor => ActualFactory.StatisticsImplementor; + + ISQLExceptionConverter ISessionFactoryImplementor.SQLExceptionConverter => ActualFactory.SQLExceptionConverter; + + Settings ISessionFactoryImplementor.Settings => ActualFactory.Settings; + + IEntityNotFoundDelegate ISessionFactoryImplementor.EntityNotFoundDelegate => ActualFactory.EntityNotFoundDelegate; + + SQLFunctionRegistry ISessionFactoryImplementor.SQLFunctionRegistry => ActualFactory.SQLFunctionRegistry; + + IDictionary ISessionFactoryImplementor.GetAllSecondLevelCacheRegions() + { + return ActualFactory.GetAllSecondLevelCacheRegions(); + } + + IEntityPersister ISessionFactoryImplementor.GetEntityPersister(string entityName) + { + return ActualFactory.GetEntityPersister(entityName); + } + + ICollectionPersister ISessionFactoryImplementor.GetCollectionPersister(string role) + { + return ActualFactory.GetCollectionPersister(role); + } + + IType[] ISessionFactoryImplementor.GetReturnTypes(string queryString) + { + return ActualFactory.GetReturnTypes(queryString); + } + + string[] ISessionFactoryImplementor.GetReturnAliases(string queryString) + { + return ActualFactory.GetReturnAliases(queryString); + } + + string[] ISessionFactoryImplementor.GetImplementors(string entityOrClassName) + { + return ActualFactory.GetImplementors(entityOrClassName); + } + + string ISessionFactoryImplementor.GetImportedClassName(string name) + { + return ActualFactory.GetImportedClassName(name); + } + + IQueryCache ISessionFactoryImplementor.QueryCache => ActualFactory.QueryCache; + + IQueryCache ISessionFactoryImplementor.GetQueryCache(string regionName) + { + return ActualFactory.GetQueryCache(regionName); + } + + NamedQueryDefinition ISessionFactoryImplementor.GetNamedQuery(string queryName) + { + return ActualFactory.GetNamedQuery(queryName); + } + + NamedSQLQueryDefinition ISessionFactoryImplementor.GetNamedSQLQuery(string queryName) + { + return ActualFactory.GetNamedSQLQuery(queryName); + } + + ResultSetMappingDefinition ISessionFactoryImplementor.GetResultSetMapping(string resultSetRef) + { + return ActualFactory.GetResultSetMapping(resultSetRef); + } + + IIdentifierGenerator ISessionFactoryImplementor.GetIdentifierGenerator(string rootEntityName) + { + return ActualFactory.GetIdentifierGenerator(rootEntityName); + } + + ICache ISessionFactoryImplementor.GetSecondLevelCacheRegion(string regionName) + { + return ActualFactory.GetSecondLevelCacheRegion(regionName); + } + + ISet ISessionFactoryImplementor.GetCollectionRolesByEntityParticipant(string entityName) + { + return ActualFactory.GetCollectionRolesByEntityParticipant(entityName); + } + + ICurrentSessionContext ISessionFactoryImplementor.CurrentSessionContext => ActualFactory.CurrentSessionContext; + + IEntityPersister ISessionFactoryImplementor.TryGetEntityPersister(string entityName) + { + return ActualFactory.TryGetEntityPersister(entityName); + } + + string ISessionFactoryImplementor.TryGetGuessEntityName(System.Type implementor) + { + return ActualFactory.TryGetGuessEntityName(implementor); + } + + #endregion + + public static ISessionCreationOptions GetCreationOptions(ISessionBuilder sessionBuilder) where T : ISessionBuilder + { + return (sessionBuilder as SessionBuilder)?.CreationOptions ?? + (ISessionCreationOptions)sessionBuilder; + } + + public static ISessionCreationOptions GetCreationOptions(IStatelessSessionBuilder sessionBuilder) + { + return ((StatelessSessionBuilder)sessionBuilder).CreationOptions; + } + + internal class SessionBuilder : ISessionBuilder + { + private readonly ISessionBuilder _actualBuilder; + private readonly DebugSessionFactory _debugFactory; + + internal ISessionCreationOptions CreationOptions => (ISessionCreationOptions)_actualBuilder; + + public SessionBuilder(ISessionBuilder actualBuilder, DebugSessionFactory debugFactory) + { + _actualBuilder = actualBuilder; + _debugFactory = debugFactory; + } + + ISession ISessionBuilder.OpenSession() + { + var s = _actualBuilder.OpenSession(); + _debugFactory._openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + #region Delegated calls without any changes + + ISessionBuilder ISessionBuilder.Interceptor(IInterceptor interceptor) + { + _actualBuilder.Interceptor(interceptor); + return this; + } + + ISessionBuilder ISessionBuilder.NoInterceptor() + { + _actualBuilder.NoInterceptor(); + return this; + } + + ISessionBuilder ISessionBuilder.Connection(DbConnection connection) + { + _actualBuilder.Connection(connection); + return this; + } + + ISessionBuilder ISessionBuilder.ConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) + { + _actualBuilder.ConnectionReleaseMode(connectionReleaseMode); + return this; + } + + ISessionBuilder ISessionBuilder.AutoClose(bool autoClose) + { + _actualBuilder.AutoClose(autoClose); + return this; + } + + ISessionBuilder ISessionBuilder.FlushMode(FlushMode flushMode) + { + _actualBuilder.FlushMode(flushMode); + return this; + } + + #endregion + } + + internal class StatelessSessionBuilder : IStatelessSessionBuilder + { + private readonly IStatelessSessionBuilder _actualBuilder; + private readonly DebugSessionFactory _debugFactory; + + internal ISessionCreationOptions CreationOptions => (ISessionCreationOptions)_actualBuilder; + + public StatelessSessionBuilder(IStatelessSessionBuilder actualBuilder, DebugSessionFactory debugFactory) + { + _actualBuilder = actualBuilder; + _debugFactory = debugFactory; + } + + IStatelessSession IStatelessSessionBuilder.OpenStatelessSession() + { + var s = _actualBuilder.OpenStatelessSession(); + _debugFactory._openedSessions.Add(s.GetSessionImplementation()); + return s; + } + + #region Delegated calls without any changes + + IStatelessSessionBuilder IStatelessSessionBuilder.Connection(DbConnection connection) + { + _actualBuilder.Connection(connection); + return this; + } + + #endregion + } + } +} diff --git a/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs b/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs index 304814d8381..f96ece69a8e 100644 --- a/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs +++ b/src/NHibernate.Test/DriverTest/SqlClientDriverFixture.cs @@ -90,7 +90,7 @@ public void Crud() [Test] public void QueryPlansAreReused() { - if (!(sessions.ConnectionProvider.Driver is SqlClientDriver)) + if (!(Sfi.ConnectionProvider.Driver is SqlClientDriver)) Assert.Ignore("Test designed for SqlClientDriver only"); using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs b/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs index 7242ed0d712..7e0faa577a5 100644 --- a/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs +++ b/src/NHibernate.Test/Events/Collections/AbstractCollectionEventFixture.cs @@ -50,7 +50,7 @@ protected override void OnTearDown() [Test] public void SaveParentEmptyChildren() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNoChildren("parent"); Assert.That(parent.Children.Count, Is.EqualTo(0)); int index = 0; @@ -73,7 +73,7 @@ public void SaveParentEmptyChildren() [Test] public virtual void SaveParentOneChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); int index = 0; CheckResult(listeners, listeners.PreCollectionRecreate, parent, index++); @@ -91,7 +91,7 @@ public virtual void SaveParentOneChild() [Test] public void UpdateParentNullToOneChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNullChildren("parent"); listeners.Clear(); Assert.That(parent.Children, Is.Null); @@ -121,7 +121,7 @@ public void UpdateParentNullToOneChild() [Test] public void UpdateParentNoneToOneChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNoChildren("parent"); listeners.Clear(); Assert.That(parent.Children.Count, Is.EqualTo(0)); @@ -150,7 +150,7 @@ public void UpdateParentNoneToOneChild() [Test] public void UpdateParentOneToTwoChildren() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); Assert.That(parent.Children.Count, Is.EqualTo(1)); listeners.Clear(); @@ -179,7 +179,7 @@ public void UpdateParentOneToTwoChildren() [Test] public virtual void UpdateParentOneToTwoSameChildren() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IChild child = GetFirstChild(parent.Children); Assert.That(parent.Children.Count, Is.EqualTo(1)); @@ -227,7 +227,7 @@ public virtual void UpdateParentOneToTwoSameChildren() [Test] public void UpdateParentNullToOneChildDiffCollection() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNullChildren("parent"); listeners.Clear(); Assert.That(parent.Children, Is.Null); @@ -259,7 +259,7 @@ public void UpdateParentNullToOneChildDiffCollection() [Test] public void UpdateParentNoneToOneChildDiffCollection() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNoChildren("parent"); listeners.Clear(); Assert.That(parent.Children.Count, Is.EqualTo(0)); @@ -292,7 +292,7 @@ public void UpdateParentNoneToOneChildDiffCollection() [Test] public void UpdateParentOneChildDiffCollectionSameChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IChild child = GetFirstChild(parent.Children); listeners.Clear(); @@ -341,7 +341,7 @@ public void UpdateParentOneChildDiffCollectionSameChild() [Test] public void UpdateParentOneChildDiffCollectionDiffChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IChild oldChild = GetFirstChild(parent.Children); listeners.Clear(); @@ -389,7 +389,7 @@ public void UpdateParentOneChildDiffCollectionDiffChild() [Test] public void UpdateParentOneChildToNoneByRemove() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); Assert.That(parent.Children.Count, Is.EqualTo(1)); IChild child = GetFirstChild(parent.Children); @@ -432,7 +432,7 @@ public void UpdateParentOneChildToNoneByRemove() [Test] public void UpdateParentOneChildToNoneByClear() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); Assert.That(parent.Children.Count, Is.EqualTo(1)); IChild child = GetFirstChild(parent.Children); @@ -474,7 +474,7 @@ public void UpdateParentOneChildToNoneByClear() [Test] public void UpdateParentTwoChildrenToOne() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); Assert.That(parent.Children.Count, Is.EqualTo(1)); IChild oldChild = GetFirstChild(parent.Children); @@ -525,7 +525,7 @@ public void UpdateParentTwoChildrenToOne() [Test] public void DeleteParentWithNullChildren() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNullChildren("parent"); listeners.Clear(); ISession s = OpenSession(); @@ -544,7 +544,7 @@ public void DeleteParentWithNullChildren() [Test] public void DeleteParentWithNoChildren() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithNoChildren("parent"); listeners.Clear(); ISession s = OpenSession(); @@ -564,7 +564,7 @@ public void DeleteParentWithNoChildren() [Test] public void DeleteParentAndChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IChild child = GetFirstChild(parent.Children); listeners.Clear(); @@ -604,7 +604,7 @@ public void DeleteParentAndChild() [Test] public void MoveChildToDifferentParent() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IParentWithCollection otherParent = CreateParentWithOneChild("otherParent", "otherChild"); IChild child = GetFirstChild(parent.Children); @@ -651,7 +651,7 @@ public void MoveChildToDifferentParent() [Test] public void MoveAllChildrenToDifferentParent() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IParentWithCollection otherParent = CreateParentWithOneChild("otherParent", "otherChild"); IChild child = GetFirstChild(parent.Children); @@ -698,7 +698,7 @@ public void MoveAllChildrenToDifferentParent() [Test] public void MoveCollectionToDifferentParent() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IParentWithCollection otherParent = CreateParentWithOneChild("otherParent", "otherChild"); listeners.Clear(); @@ -749,7 +749,7 @@ public void MoveCollectionToDifferentParent() [Test] public void MoveCollectionToDifferentParentFlushMoveToDifferentParent() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); IParentWithCollection otherParent = CreateParentWithOneChild("otherParent", "otherChild"); IParentWithCollection otherOtherParent = CreateParentWithNoChildren("otherParent"); diff --git a/src/NHibernate.Test/Events/Collections/Association/AbstractAssociationCollectionEventFixture.cs b/src/NHibernate.Test/Events/Collections/Association/AbstractAssociationCollectionEventFixture.cs index 829ca2da054..4057d3af2ca 100644 --- a/src/NHibernate.Test/Events/Collections/Association/AbstractAssociationCollectionEventFixture.cs +++ b/src/NHibernate.Test/Events/Collections/Association/AbstractAssociationCollectionEventFixture.cs @@ -8,7 +8,7 @@ public abstract class AbstractAssociationCollectionEventFixture : AbstractCollec [Test] public void DeleteParentButNotChild() { - CollectionListeners listeners = new CollectionListeners(sessions); + CollectionListeners listeners = new CollectionListeners(Sfi); IParentWithCollection parent = CreateParentWithOneChild("parent", "child"); ChildEntity child = (ChildEntity) GetFirstChild(parent.Children); listeners.Clear(); diff --git a/src/NHibernate.Test/Events/Collections/CollectionListeners.cs b/src/NHibernate.Test/Events/Collections/CollectionListeners.cs index fd697ba2e2d..1350b188859 100644 --- a/src/NHibernate.Test/Events/Collections/CollectionListeners.cs +++ b/src/NHibernate.Test/Events/Collections/CollectionListeners.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using NHibernate.Event; using NHibernate.Event.Default; -using NHibernate.Impl; namespace NHibernate.Test.Events.Collections { @@ -28,22 +27,21 @@ public CollectionListeners(ISessionFactory sf) postCollectionRecreateListener = new PostCollectionRecreateListener(this); postCollectionRemoveListener = new PostCollectionRemoveListener(this); postCollectionUpdateListener = new PostCollectionUpdateListener(this); - SessionFactoryImpl impl = (SessionFactoryImpl) sf; - impl.EventListeners.InitializeCollectionEventListeners = new IInitializeCollectionEventListener[] - {initializeCollectionListener}; - - impl.EventListeners.PreCollectionRecreateEventListeners = new IPreCollectionRecreateEventListener[] - {preCollectionRecreateListener}; - impl.EventListeners.PostCollectionRecreateEventListeners = new IPostCollectionRecreateEventListener[] - {postCollectionRecreateListener}; - impl.EventListeners.PreCollectionRemoveEventListeners = new IPreCollectionRemoveEventListener[] - {preCollectionRemoveListener}; - impl.EventListeners.PostCollectionRemoveEventListeners = new IPostCollectionRemoveEventListener[] - {postCollectionRemoveListener}; - impl.EventListeners.PreCollectionUpdateEventListeners = new IPreCollectionUpdateEventListener[] - {preCollectionUpdateListener}; - impl.EventListeners.PostCollectionUpdateEventListeners = new IPostCollectionUpdateEventListener[] - {postCollectionUpdateListener}; + var listeners = ((DebugSessionFactory)sf).EventListeners; + listeners.InitializeCollectionEventListeners = + new IInitializeCollectionEventListener[] { initializeCollectionListener }; + listeners.PreCollectionRecreateEventListeners = + new IPreCollectionRecreateEventListener[] { preCollectionRecreateListener }; + listeners.PostCollectionRecreateEventListeners = + new IPostCollectionRecreateEventListener[] { postCollectionRecreateListener }; + listeners.PreCollectionRemoveEventListeners = + new IPreCollectionRemoveEventListener[] { preCollectionRemoveListener }; + listeners.PostCollectionRemoveEventListeners = + new IPostCollectionRemoveEventListener[] { postCollectionRemoveListener }; + listeners.PreCollectionUpdateEventListeners = + new IPreCollectionUpdateEventListener[] { preCollectionUpdateListener }; + listeners.PostCollectionUpdateEventListeners = + new IPostCollectionUpdateEventListener[] { postCollectionUpdateListener }; } public IList ListenersCalled @@ -168,7 +166,7 @@ public override void OnInitializeCollection(InitializeCollectionEvent @event) public class PostCollectionRecreateListener : AbstractListener, IPostCollectionRecreateEventListener { - public PostCollectionRecreateListener(CollectionListeners listeners) : base(listeners) {} + public PostCollectionRecreateListener(CollectionListeners listeners) : base(listeners) { } #region IPostCollectionRecreateEventListener Members @@ -186,7 +184,7 @@ public void OnPostRecreateCollection(PostCollectionRecreateEvent @event) public class PostCollectionRemoveListener : AbstractListener, IPostCollectionRemoveEventListener { - public PostCollectionRemoveListener(CollectionListeners listeners) : base(listeners) {} + public PostCollectionRemoveListener(CollectionListeners listeners) : base(listeners) { } #region IPostCollectionRemoveEventListener Members @@ -204,7 +202,7 @@ public void OnPostRemoveCollection(PostCollectionRemoveEvent @event) public class PostCollectionUpdateListener : AbstractListener, IPostCollectionUpdateEventListener { - public PostCollectionUpdateListener(CollectionListeners listeners) : base(listeners) {} + public PostCollectionUpdateListener(CollectionListeners listeners) : base(listeners) { } #region IPostCollectionUpdateEventListener Members @@ -222,7 +220,7 @@ public void OnPostUpdateCollection(PostCollectionUpdateEvent @event) public class PreCollectionRecreateListener : AbstractListener, IPreCollectionRecreateEventListener { - public PreCollectionRecreateListener(CollectionListeners listeners) : base(listeners) {} + public PreCollectionRecreateListener(CollectionListeners listeners) : base(listeners) { } #region IPreCollectionRecreateEventListener Members @@ -240,7 +238,7 @@ public void OnPreRecreateCollection(PreCollectionRecreateEvent @event) public class PreCollectionRemoveListener : AbstractListener, IPreCollectionRemoveEventListener { - public PreCollectionRemoveListener(CollectionListeners listeners) : base(listeners) {} + public PreCollectionRemoveListener(CollectionListeners listeners) : base(listeners) { } #region IPreCollectionRemoveEventListener Members @@ -258,7 +256,7 @@ public void OnPreRemoveCollection(PreCollectionRemoveEvent @event) public class PreCollectionUpdateListener : AbstractListener, IPreCollectionUpdateEventListener { - public PreCollectionUpdateListener(CollectionListeners listeners) : base(listeners) {} + public PreCollectionUpdateListener(CollectionListeners listeners) : base(listeners) { } #region IPreCollectionUpdateEventListener Members diff --git a/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs b/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs index 75096a76847..f09852303d8 100644 --- a/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs +++ b/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs @@ -22,7 +22,7 @@ protected override IList Mappings [Test] public void ImplicitFlush() { - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] { new AssertOldStatePostListener( eArgs => @@ -44,13 +44,13 @@ public void ImplicitFlush() } DbCleanup(); - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; } [Test] public void ExplicitUpdate() { - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] { new AssertOldStatePostListener( eArgs => @@ -73,13 +73,13 @@ public void ExplicitUpdate() } DbCleanup(); - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; } [Test] public void WithDetachedObject() { - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] { new AssertOldStatePostListener( eArgs => @@ -111,7 +111,7 @@ public void WithDetachedObject() } DbCleanup(); - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; } [Test] @@ -119,7 +119,7 @@ public void UpdateDetachedObject() { // When the update is used directly as method to reattach a entity the OldState is null // that mean that NH should not retrieve info from DB - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] { new AssertOldStatePostListener( eArgs => @@ -151,13 +151,13 @@ public void UpdateDetachedObject() } DbCleanup(); - ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; + ((DebugSessionFactory) Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; } [Test] public void UpdateDetachedObjectWithLock() { - ((SessionFactoryImpl)sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] + ((DebugSessionFactory)Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[] { new AssertOldStatePostListener( eArgs => @@ -190,7 +190,7 @@ public void UpdateDetachedObjectWithLock() } DbCleanup(); - ((SessionFactoryImpl)sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; + ((DebugSessionFactory)Sfi).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0]; } private void DbCleanup() { diff --git a/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs b/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs index 3f4ca4e5180..5af17f0a647 100644 --- a/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs +++ b/src/NHibernate.Test/ExceptionsTest/NullQueryTest.cs @@ -36,7 +36,7 @@ public void BadGrammar() catch (Exception sqle) { Assert.DoesNotThrow( - () => ADOExceptionHelper.Convert(sessions.SQLExceptionConverter, sqle, "could not get or update next value", null)); + () => ADOExceptionHelper.Convert(Sfi.SQLExceptionConverter, sqle, "could not get or update next value", null)); } finally { diff --git a/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs b/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs index dba4199c22e..179a50a862d 100644 --- a/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs +++ b/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs @@ -71,7 +71,7 @@ public void IntegrityViolation() { //ISQLExceptionConverter converter = Dialect.BuildSQLExceptionConverter(); - ISQLExceptionConverter converter = sessions.Settings.SqlExceptionConverter; + ISQLExceptionConverter converter = Sfi.Settings.SqlExceptionConverter; ISession session = OpenSession(); session.BeginTransaction(); @@ -134,7 +134,7 @@ public void IntegrityViolation() public void BadGrammar() { //ISQLExceptionConverter converter = Dialect.BuildSQLExceptionConverter(); - ISQLExceptionConverter converter = sessions.Settings.SqlExceptionConverter; + ISQLExceptionConverter converter = Sfi.Settings.SqlExceptionConverter; ISession session = OpenSession(); var connection = session.Connection; diff --git a/src/NHibernate.Test/ExpressionTest/Projection/ProjectionSqlFixture.cs b/src/NHibernate.Test/ExpressionTest/Projection/ProjectionSqlFixture.cs index 1c11b8dfca2..b214be04c97 100644 --- a/src/NHibernate.Test/ExpressionTest/Projection/ProjectionSqlFixture.cs +++ b/src/NHibernate.Test/ExpressionTest/Projection/ProjectionSqlFixture.cs @@ -39,7 +39,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from ProjectionTestClass"); s.Flush(); diff --git a/src/NHibernate.Test/ExpressionTest/SubQueries/SubQueriesSqlFixture.cs b/src/NHibernate.Test/ExpressionTest/SubQueries/SubQueriesSqlFixture.cs index f287022b604..e4e7944dbe0 100644 --- a/src/NHibernate.Test/ExpressionTest/SubQueries/SubQueriesSqlFixture.cs +++ b/src/NHibernate.Test/ExpressionTest/SubQueries/SubQueriesSqlFixture.cs @@ -59,7 +59,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from Comment"); s.Delete("from Post"); @@ -78,7 +78,7 @@ public void CanQueryBlogByItsPosts() .Add(Expression.Eq("id", post1.PostId)) .Add(Property.ForName("posts.Blog.id").EqProperty("blog.id")); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { IList list = s.CreateCriteria(typeof(Blog), "blog") .Add(Subqueries.Exists(dc)) diff --git a/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs b/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs index c9e46da1add..d803dcab1ed 100644 --- a/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs +++ b/src/NHibernate.Test/Extralazy/ExtraLazyFixture.cs @@ -54,8 +54,8 @@ public void ExtraLazyWithWhereClause() t.Commit(); } - sessions.Evict(typeof (User)); - sessions.Evict(typeof (Photo)); + Sfi.Evict(typeof (User)); + Sfi.Evict(typeof (Photo)); } [Test] diff --git a/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs b/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs index 4f882bcc81a..5294d8251f5 100644 --- a/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs +++ b/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs @@ -29,11 +29,11 @@ public void SecondLevelCachedCollectionsFiltering() // Force a collection into the second level cache, with its non-filtered elements Salesperson sp = (Salesperson) session.Load(typeof(Salesperson), testData.steveId); NHibernateUtil.Initialize(sp.Orders); - ICollectionPersister persister = ((ISessionFactoryImplementor) sessions) + ICollectionPersister persister = ((ISessionFactoryImplementor) Sfi) .GetCollectionPersister(typeof(Salesperson).FullName + ".Orders"); Assert.IsTrue(persister.HasCache, "No cache for collection"); CacheKey cacheKey = - new CacheKey(testData.steveId, persister.KeyType, persister.Role, (ISessionFactoryImplementor) sessions); + new CacheKey(testData.steveId, persister.KeyType, persister.Role, (ISessionFactoryImplementor) Sfi); CollectionCacheEntry cachedData = (CollectionCacheEntry)persister.Cache.Cache.Get(cacheKey); Assert.IsNotNull(cachedData, "collection was not in cache"); diff --git a/src/NHibernate.Test/GenericTest/BagGeneric/BagGenericFixture.cs b/src/NHibernate.Test/GenericTest/BagGeneric/BagGenericFixture.cs index f27ead9bdcd..eb84a62ab9c 100644 --- a/src/NHibernate.Test/GenericTest/BagGeneric/BagGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/BagGeneric/BagGenericFixture.cs @@ -21,7 +21,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/GenericTest/IdBagGeneric/IdBagGenericFixture.cs b/src/NHibernate.Test/GenericTest/IdBagGeneric/IdBagGenericFixture.cs index cefbf53391e..3796a739c5b 100644 --- a/src/NHibernate.Test/GenericTest/IdBagGeneric/IdBagGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/IdBagGeneric/IdBagGenericFixture.cs @@ -21,7 +21,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); diff --git a/src/NHibernate.Test/GenericTest/ListGeneric/ListGenericFixture.cs b/src/NHibernate.Test/GenericTest/ListGeneric/ListGenericFixture.cs index 7f13cedfaa0..c255a8aee06 100644 --- a/src/NHibernate.Test/GenericTest/ListGeneric/ListGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/ListGeneric/ListGenericFixture.cs @@ -22,7 +22,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs b/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs index e1a0d9a8c38..bfa6a432aa3 100644 --- a/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/MapGeneric/MapGenericFixture.cs @@ -25,7 +25,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); @@ -206,7 +206,7 @@ public void SortedCollections() { a = s.Load( a.Id ); - ISessionFactoryImplementor si = (ISessionFactoryImplementor)sessions; + ISessionFactoryImplementor si = (ISessionFactoryImplementor)Sfi; ICollectionPersister cpSortedList = si.GetCollectionPersister(typeof(A).FullName + ".SortedList"); ICollectionPersister cpSortedDictionary = si.GetCollectionPersister(typeof(A).FullName + ".SortedDictionary"); diff --git a/src/NHibernate.Test/GenericTest/SetGeneric/SetGenericFixture.cs b/src/NHibernate.Test/GenericTest/SetGeneric/SetGenericFixture.cs index 6ee8408eee0..185c9c7096d 100644 --- a/src/NHibernate.Test/GenericTest/SetGeneric/SetGenericFixture.cs +++ b/src/NHibernate.Test/GenericTest/SetGeneric/SetGenericFixture.cs @@ -22,7 +22,7 @@ protected override string MappingsAssembly protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs b/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs index 1422552c4db..a557e2879e2 100644 --- a/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs +++ b/src/NHibernate.Test/GhostProperty/GhostPropertyFixture.cs @@ -57,12 +57,13 @@ protected override void OnTearDown() } } - protected override void BuildSessionFactory() + protected override DebugSessionFactory BuildSessionFactory() { using (var logSpy = new LogSpy(typeof(EntityMetamodel))) { - base.BuildSessionFactory(); + var factory = base.BuildSessionFactory(); log = logSpy.GetWholeLog(); + return factory; } } diff --git a/src/NHibernate.Test/Hql/Ast/BaseFixture.cs b/src/NHibernate.Test/Hql/Ast/BaseFixture.cs index f20fa03a654..bcdcae76106 100644 --- a/src/NHibernate.Test/Hql/Ast/BaseFixture.cs +++ b/src/NHibernate.Test/Hql/Ast/BaseFixture.cs @@ -38,7 +38,7 @@ public string GetSql(string query) public string GetSql(string query, IDictionary replacements) { - var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, sessions).Parse(), emptyfilters, sessions); + var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, Sfi).Parse(), emptyfilters, Sfi); qt.Compile(replacements, false); return qt.SQLString; } diff --git a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs index a59720c1d19..d4a2bc73ba7 100644 --- a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs +++ b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs @@ -163,7 +163,7 @@ public void InsertAcrossMappedJoinFails() public void InsertWithGeneratedId() { // Make sure the env supports bulk inserts with generated ids... - IEntityPersister persister = sessions.GetEntityPersister(typeof (PettingZoo).FullName); + IEntityPersister persister = Sfi.GetEntityPersister(typeof (PettingZoo).FullName); IIdentifierGenerator generator = persister.IdentifierGenerator; if (!HqlSqlWalker.SupportsIdGenWithBulkInsertion(generator)) { @@ -206,7 +206,7 @@ public void InsertWithGeneratedId() public void InsertWithGeneratedVersionAndId() { // Make sure the env supports bulk inserts with generated ids... - IEntityPersister persister = sessions.GetEntityPersister(typeof (IntegerVersioned).FullName); + IEntityPersister persister = Sfi.GetEntityPersister(typeof (IntegerVersioned).FullName); IIdentifierGenerator generator = persister.IdentifierGenerator; if (!HqlSqlWalker.SupportsIdGenWithBulkInsertion(generator)) { @@ -257,7 +257,7 @@ public void InsertWithGeneratedVersionAndId() public void InsertWithGeneratedTimestampVersion() { // Make sure the env supports bulk inserts with generated ids... - IEntityPersister persister = sessions.GetEntityPersister(typeof (TimestampVersioned).FullName); + IEntityPersister persister = Sfi.GetEntityPersister(typeof (TimestampVersioned).FullName); IIdentifierGenerator generator = persister.IdentifierGenerator; if (!HqlSqlWalker.SupportsIdGenWithBulkInsertion(generator)) { diff --git a/src/NHibernate.Test/Hql/Ast/HqlFixture.cs b/src/NHibernate.Test/Hql/Ast/HqlFixture.cs index 22f119ecddf..9832fd65fad 100644 --- a/src/NHibernate.Test/Hql/Ast/HqlFixture.cs +++ b/src/NHibernate.Test/Hql/Ast/HqlFixture.cs @@ -15,7 +15,7 @@ public class HqlFixture : BaseFixture { protected HQLQueryPlan CreateQueryPlan(string hql, bool scalar) { - return new QueryExpressionPlan(new StringQueryExpression(hql), scalar, new CollectionHelper.EmptyMapClass(), sessions); + return new QueryExpressionPlan(new StringQueryExpression(hql), scalar, new CollectionHelper.EmptyMapClass(), Sfi); } protected HQLQueryPlan CreateQueryPlan(string hql) diff --git a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/BasicForcedTableSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/BasicForcedTableSequenceTest.cs index 9bff571ff5b..dbaa83b0096 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/BasicForcedTableSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/BasicForcedTableSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/HiLoForcedTableSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/HiLoForcedTableSequenceTest.cs index 62ebeb2657f..3601715c7cf 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/HiLoForcedTableSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/HiLoForcedTableSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/PooledForcedTableSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/PooledForcedTableSequenceTest.cs index 7f2595119b4..54873e8edea 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/PooledForcedTableSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Forcedtable/PooledForcedTableSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Sequence/BasicSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Sequence/BasicSequenceTest.cs index dabab1baba8..f2fbb1ca9d2 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Sequence/BasicSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Sequence/BasicSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Sequence/DefaultOptimizedSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Sequence/DefaultOptimizedSequenceTest.cs index 9b628774fd2..050aebcb577 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Sequence/DefaultOptimizedSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Sequence/DefaultOptimizedSequenceTest.cs @@ -43,7 +43,7 @@ public void CorrectOptimizerChosenAsDefault() // if an increment size greater than 1 is specified, and that the global // property Cfg.Environment.PreferPooledValuesLo takes effect. - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Sequence/HiLoSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Sequence/HiLoSequenceTest.cs index 85fa5199167..4061291fa5c 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Sequence/HiLoSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Sequence/HiLoSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Sequence/PooledSequenceTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Sequence/PooledSequenceTest.cs index 4ee43e6178c..e4d6eebc7e6 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Sequence/PooledSequenceTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Sequence/PooledSequenceTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (SequenceStyleGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Table/BasicTableTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Table/BasicTableTest.cs index f90485ddbe7..fb930134b4a 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Table/BasicTableTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Table/BasicTableTest.cs @@ -21,7 +21,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (TableGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Table/HiLoTableTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Table/HiLoTableTest.cs index 81f19820f8a..cabe7cba7a1 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Table/HiLoTableTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Table/HiLoTableTest.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (TableGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Table/PooledLoTableTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Table/PooledLoTableTest.cs index d8f736c3713..9134f668169 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Table/PooledLoTableTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Table/PooledLoTableTest.cs @@ -21,7 +21,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (TableGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/IdGen/Enhanced/Table/PooledTableTest.cs b/src/NHibernate.Test/IdGen/Enhanced/Table/PooledTableTest.cs index ff96ebe5ded..bf64540f726 100644 --- a/src/NHibernate.Test/IdGen/Enhanced/Table/PooledTableTest.cs +++ b/src/NHibernate.Test/IdGen/Enhanced/Table/PooledTableTest.cs @@ -21,7 +21,7 @@ protected override string MappingsAssembly [Test] public void TestNormalBoundary() { - var persister = sessions.GetEntityPersister(typeof(Entity).FullName); + var persister = Sfi.GetEntityPersister(typeof(Entity).FullName); Assert.That(persister.IdentifierGenerator, Is.TypeOf()); var generator = (TableGenerator)persister.IdentifierGenerator; diff --git a/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithManyToManyTest.cs b/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithManyToManyTest.cs index 1dc608a404a..b73097d97c8 100644 --- a/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithManyToManyTest.cs +++ b/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithManyToManyTest.cs @@ -33,11 +33,11 @@ protected override void OnSetUp() { base.OnSetUp(); - isPlanContractsInverse = sessions.GetCollectionPersister(typeof(Plan).FullName + ".Contracts").IsInverse; + isPlanContractsInverse = Sfi.GetCollectionPersister(typeof(Plan).FullName + ".Contracts").IsInverse; try { - sessions.GetCollectionPersister(typeof(Contract).FullName + ".Plans"); + Sfi.GetCollectionPersister(typeof(Contract).FullName + ".Plans"); isPlanContractsBidirectional = true; } catch (MappingException) @@ -45,8 +45,8 @@ protected override void OnSetUp() isPlanContractsBidirectional = false; } - isPlanVersioned = sessions.GetEntityPersister(typeof(Plan).FullName).IsVersioned; - isContractVersioned = sessions.GetEntityPersister(typeof(Contract).FullName).IsVersioned; + isPlanVersioned = Sfi.GetEntityPersister(typeof(Plan).FullName).IsVersioned; + isContractVersioned = Sfi.GetEntityPersister(typeof(Contract).FullName).IsVersioned; } [Test] diff --git a/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithOneToManyTest.cs b/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithOneToManyTest.cs index 2061690cb08..e9e48bb7bb4 100644 --- a/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithOneToManyTest.cs +++ b/src/NHibernate.Test/Immutable/EntityWithMutableCollection/AbstractEntityWithOneToManyTest.cs @@ -41,10 +41,10 @@ protected virtual bool CheckUpdateCountsAfterRemovingElementWithoutDelete() protected override void OnSetUp() { - isContractPartiesInverse = sessions.GetCollectionPersister(typeof(Contract).FullName + ".Parties").IsInverse; + isContractPartiesInverse = Sfi.GetCollectionPersister(typeof(Contract).FullName + ".Parties").IsInverse; try { - sessions.GetEntityPersister(typeof(Party).FullName).GetPropertyType("Contract"); + Sfi.GetEntityPersister(typeof(Party).FullName).GetPropertyType("Contract"); isContractPartiesBidirectional = true; } catch (QueryException) @@ -53,7 +53,7 @@ protected override void OnSetUp() } try { - sessions.GetEntityPersister(typeof(ContractVariation).FullName).GetPropertyType("Contract"); + Sfi.GetEntityPersister(typeof(ContractVariation).FullName).GetPropertyType("Contract"); isContractVariationsBidirectional = true; } catch (QueryException) @@ -61,7 +61,7 @@ protected override void OnSetUp() isContractVariationsBidirectional = false; } - isContractVersioned = sessions.GetEntityPersister(typeof(Contract).FullName).IsVersioned; + isContractVersioned = Sfi.GetEntityPersister(typeof(Contract).FullName).IsVersioned; } [Test] diff --git a/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs b/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs index 3afe34147c7..df305688a94 100644 --- a/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs +++ b/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs @@ -19,12 +19,13 @@ protected override IList Mappings get { return new[] { "LazyProperty.Mappings.hbm.xml" }; } } - protected override void BuildSessionFactory() + protected override DebugSessionFactory BuildSessionFactory() { using (var logSpy = new LogSpy(typeof(EntityMetamodel))) { - base.BuildSessionFactory(); + var factory = base.BuildSessionFactory(); log = logSpy.GetWholeLog(); + return factory; } } diff --git a/src/NHibernate.Test/Legacy/ABCProxyTest.cs b/src/NHibernate.Test/Legacy/ABCProxyTest.cs index 81b86d5d5c2..a5de2d6b684 100644 --- a/src/NHibernate.Test/Legacy/ABCProxyTest.cs +++ b/src/NHibernate.Test/Legacy/ABCProxyTest.cs @@ -264,13 +264,9 @@ public void SubclassMap() s.Close(); } - [Test] + [Test, Ignore("ANTLR parser : Not supported ")] public void OnoToOneComparing() { - if (IsAntlrParser) - { - Assert.Ignore("ANTLR parser : Not supported "); - } A a = new A(); E d1 = new E(); C1 c = new C1(); diff --git a/src/NHibernate.Test/Legacy/FooBarTest.cs b/src/NHibernate.Test/Legacy/FooBarTest.cs index e6995cfd992..a2cba12f0b4 100644 --- a/src/NHibernate.Test/Legacy/FooBarTest.cs +++ b/src/NHibernate.Test/Legacy/FooBarTest.cs @@ -266,7 +266,7 @@ public void DereferenceLazyCollection() s.Flush(); } - sessions.EvictCollection("NHibernate.DomainModel.Baz.FooSet"); + Sfi.EvictCollection("NHibernate.DomainModel.Baz.FooSet"); using (ISession s = OpenSession()) { @@ -323,7 +323,7 @@ public void MoveLazyCollection() s.Flush(); } - sessions.EvictCollection("NHibernate.DomainModel.Baz.FooSet"); + Sfi.EvictCollection("NHibernate.DomainModel.Baz.FooSet"); using (ISession s = OpenSession()) { @@ -1677,7 +1677,7 @@ public void IdBag() [Test] public void ForceOuterJoin() { - if (sessions.Settings.IsOuterJoinFetchEnabled == false) + if (Sfi.Settings.IsOuterJoinFetchEnabled == false) { // don't bother to run the test if we can't test it return; @@ -3554,7 +3554,7 @@ public void Versioning() txn.Commit(); } - sessions.Evict(typeof(Glarch)); + Sfi.Evict(typeof(Glarch)); using (ISession s = OpenSession()) using (ITransaction txn = s.BeginTransaction()) @@ -3576,7 +3576,7 @@ public void Versioning() txn.Commit(); } - sessions.Evict(typeof(Glarch)); + Sfi.Evict(typeof(Glarch)); using (ISession s = OpenSession()) using (ITransaction txn = s.BeginTransaction()) @@ -4979,7 +4979,7 @@ public void UserProvidedConnection() { using (var prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties)) using (var connection = prov.GetConnection()) - using (var s = sessions.WithOptions().Connection(connection).OpenSession()) + using (var s = Sfi.WithOptions().Connection(connection).OpenSession()) { using (var tx = s.BeginTransaction()) { @@ -5374,7 +5374,7 @@ public void ProxiesInCollections() || (b2 == barprox && !(b1 is INHibernateProxy))); //one-to-many Assert.IsTrue(baz.FooArray[0] is INHibernateProxy); //many-to-many Assert.AreEqual(bar2prox, baz.FooArray[1]); - if (sessions.Settings.IsOuterJoinFetchEnabled) + if (Sfi.Settings.IsOuterJoinFetchEnabled) { enumer = baz.FooBag.GetEnumerator(); enumer.MoveNext(); diff --git a/src/NHibernate.Test/Legacy/FumTest.cs b/src/NHibernate.Test/Legacy/FumTest.cs index 5f0ff1e9fcf..c6dfc1db938 100644 --- a/src/NHibernate.Test/Legacy/FumTest.cs +++ b/src/NHibernate.Test/Legacy/FumTest.cs @@ -615,7 +615,7 @@ public void UnflushedSessionSerialization() // NOTE: H2.1 has getSessions().openSession() here (and below), // instead of just the usual openSession() - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.FlushMode = FlushMode.Manual; @@ -654,7 +654,7 @@ public void UnflushedSessionSerialization() /////////////////////////////////////////////////////////////////////////// // Test updates across serializations - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.FlushMode = FlushMode.Manual; Simple simple = (Simple) s.Get(typeof(Simple), 10L); @@ -677,7 +677,7 @@ public void UnflushedSessionSerialization() /////////////////////////////////////////////////////////////////////////// // Test deletions across serializations - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.FlushMode = FlushMode.Manual; Simple simple = (Simple) s.Get(typeof(Simple), 10L); diff --git a/src/NHibernate.Test/Legacy/MasterDetailTest.cs b/src/NHibernate.Test/Legacy/MasterDetailTest.cs index 595793c1bf9..522c194cb90 100644 --- a/src/NHibernate.Test/Legacy/MasterDetailTest.cs +++ b/src/NHibernate.Test/Legacy/MasterDetailTest.cs @@ -1199,7 +1199,7 @@ public void QueuedBagAdds() s.Flush(); s.Close(); - sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); + Sfi.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); s = OpenSession(); a = (Assignable) s.Get(typeof(Assignable), "foo"); @@ -1211,7 +1211,7 @@ public void QueuedBagAdds() s.Flush(); s.Close(); - sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); + Sfi.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); s = OpenSession(); a = (Assignable) s.Get(typeof(Assignable), "foo"); @@ -1224,7 +1224,7 @@ public void QueuedBagAdds() Assert.AreEqual(3, a.Categories.Count); s.Close(); - sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); + Sfi.EvictCollection("NHibernate.DomainModel.Assignable.Categories"); s = OpenSession(); a = (Assignable) s.Get(typeof(Assignable), "foo"); @@ -1259,7 +1259,7 @@ public void PolymorphicCriteria() public void ToStringWithNoIdentifier() { NHibernateUtil.Entity(typeof(Master)).ToLoggableString(new Master(), - (ISessionFactoryImplementor) sessions); + (ISessionFactoryImplementor) Sfi); } [Test] diff --git a/src/NHibernate.Test/Legacy/MultiTableTest.cs b/src/NHibernate.Test/Legacy/MultiTableTest.cs index 2c6cffcabca..ee9841eb1c4 100644 --- a/src/NHibernate.Test/Legacy/MultiTableTest.cs +++ b/src/NHibernate.Test/Legacy/MultiTableTest.cs @@ -79,7 +79,7 @@ public void SubclassCollection() s.Flush(); s.Close(); - sessions.Evict(typeof(SubMulti)); + Sfi.Evict(typeof(SubMulti)); s = OpenSession(); // TODO: I don't understand why h2.0.3/h2.1 issues a select statement here diff --git a/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs b/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs index d4e5a061153..5ff2c3ee74b 100644 --- a/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs +++ b/src/NHibernate.Test/Linq/ByMethod/GroupByTests.cs @@ -534,7 +534,7 @@ public void GroupByComputedValue() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -548,7 +548,7 @@ public void GroupByComputedValueInAnonymousType() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -562,7 +562,7 @@ public void GroupByComputedValueInObjectArray() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -693,7 +693,7 @@ public void GroupByComputedValueWithJoinOnObject() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -707,7 +707,7 @@ public void GroupByComputedValueWithJoinOnId() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -721,7 +721,7 @@ public void GroupByComputedValueInAnonymousTypeWithJoinOnObject() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -735,7 +735,7 @@ public void GroupByComputedValueInAnonymousTypeWithJoinOnId() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -749,7 +749,7 @@ public void GroupByComputedValueInObjectArrayWithJoinOnObject() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -763,7 +763,7 @@ public void GroupByComputedValueInObjectArrayWithJoinOnId() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -777,7 +777,7 @@ public void GroupByComputedValueInObjectArrayWithJoinInRightSideOfCase() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -791,7 +791,7 @@ public void GroupByComputedValueFromNestedArraySelect() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); @@ -805,7 +805,7 @@ public void GroupByComputedValueFromNestedObjectSelect() { if (Dialect is FirebirdDialect) Assert.Ignore("Firebird does not support complex group by expressions"); - if (sessions.ConnectionProvider.Driver is OdbcDriver) + if (Sfi.ConnectionProvider.Driver is OdbcDriver) Assert.Ignore("SQL Server seems unable to match complex group by and select list arguments when running over ODBC."); if (Dialect is MsSqlCeDialect) Assert.Ignore("SQL Server CE does not support complex group by expressions."); diff --git a/src/NHibernate.Test/Linq/ParameterisedQueries.cs b/src/NHibernate.Test/Linq/ParameterisedQueries.cs index 298862fef3f..6456ba0963b 100644 --- a/src/NHibernate.Test/Linq/ParameterisedQueries.cs +++ b/src/NHibernate.Test/Linq/ParameterisedQueries.cs @@ -25,8 +25,8 @@ public void Identical_Expressions_Return_The_Same_Key() Expression>> london2 = () => from c in db.Customers where c.Address.City == "London" select c; - var nhLondon1 = new NhLinqExpression(london1.Body, sessions); - var nhLondon2 = new NhLinqExpression(london2.Body, sessions); + var nhLondon1 = new NhLinqExpression(london1.Body, Sfi); + var nhLondon2 = new NhLinqExpression(london2.Body, Sfi); Assert.AreEqual(nhLondon1.Key, nhLondon2.Key); } @@ -45,8 +45,8 @@ public void Expressions_Differing_Only_By_Constants_Return_The_Same_Key() Expression>> newYork = () => from c in db.Customers where c.Address.City == "New York" select c; - var nhLondon = new NhLinqExpression(london.Body, sessions); - var nhNewYork = new NhLinqExpression(newYork.Body, sessions); + var nhLondon = new NhLinqExpression(london.Body, Sfi); + var nhNewYork = new NhLinqExpression(newYork.Body, Sfi); Assert.AreEqual(nhLondon.Key, nhNewYork.Key); Assert.AreEqual(1, nhLondon.ParameterValuesByName.Count); @@ -69,8 +69,8 @@ public void CanSpecifyParameterTypeInfo() Expression>> newYork = () => from c in db.Customers where c.Address.City == "New York".MappedAs(NHibernateUtil.AnsiString) select c; - var nhLondon = new NhLinqExpression(london.Body, sessions); - var nhNewYork = new NhLinqExpression(newYork.Body, sessions); + var nhLondon = new NhLinqExpression(london.Body, Sfi); + var nhNewYork = new NhLinqExpression(newYork.Body, Sfi); var londonParameter = nhLondon.ParameterValuesByName.Single().Value; Assert.That(londonParameter.Item1, Is.EqualTo("London")); @@ -94,8 +94,8 @@ public void Different_Where_Clauses_Return_Different_Keys() Expression>> company = () => from c in db.Customers where c.CompanyName == "Acme" select c; - var nhLondon = new NhLinqExpression(london.Body, sessions); - var nhNewYork = new NhLinqExpression(company.Body, sessions); + var nhLondon = new NhLinqExpression(london.Body, Sfi); + var nhNewYork = new NhLinqExpression(company.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -113,8 +113,8 @@ public void Different_Select_Properties_Return_Different_Keys() Expression>> title = () => from c in db.Customers select c.ContactTitle; - var nhLondon = new NhLinqExpression(customerId.Body, sessions); - var nhNewYork = new NhLinqExpression(title.Body, sessions); + var nhLondon = new NhLinqExpression(customerId.Body, Sfi); + var nhNewYork = new NhLinqExpression(title.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -132,8 +132,8 @@ public void Different_Select_Types_Return_Different_Keys() Expression> customerId = () => from c in db.Customers select c.CustomerId; - var nhLondon = new NhLinqExpression(newCustomerId.Body, sessions); - var nhNewYork = new NhLinqExpression(customerId.Body, sessions); + var nhLondon = new NhLinqExpression(newCustomerId.Body, Sfi); + var nhNewYork = new NhLinqExpression(customerId.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -151,8 +151,8 @@ public void Different_Select_Member_Initialisation_Returns_Different_Keys() Expression> customerId = () => from c in db.Customers select new { Title = c.ContactTitle, Id = c.CustomerId }; - var nhLondon = new NhLinqExpression(newCustomerId.Body, sessions); - var nhNewYork = new NhLinqExpression(customerId.Body, sessions); + var nhLondon = new NhLinqExpression(newCustomerId.Body, Sfi); + var nhNewYork = new NhLinqExpression(customerId.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -170,8 +170,8 @@ public void Different_Conditionals_Return_Different_Keys() Expression> customerId = () => from c in db.Customers select new { Desc = c.CustomerId != "1" ? "First" : "Not First" }; - var nhLondon = new NhLinqExpression(newCustomerId.Body, sessions); - var nhNewYork = new NhLinqExpression(customerId.Body, sessions); + var nhLondon = new NhLinqExpression(newCustomerId.Body, Sfi); + var nhNewYork = new NhLinqExpression(customerId.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -189,8 +189,8 @@ public void Different_Unary_Operation_Returns_Different_Keys() Expression> customerId = () => from c in db.Customers where !(c.CustomerId == "1") select c; - var nhLondon = new NhLinqExpression(newCustomerId.Body, sessions); - var nhNewYork = new NhLinqExpression(customerId.Body, sessions); + var nhLondon = new NhLinqExpression(newCustomerId.Body, Sfi); + var nhNewYork = new NhLinqExpression(customerId.Body, Sfi); Assert.AreNotEqual(nhLondon.Key, nhNewYork.Key); } @@ -204,8 +204,8 @@ public void Different_OfType_Returns_Different_Keys() Expression> ofType1 = () => (from a in session.Query().OfType() where a.Pregnant select a.Id); Expression> ofType2 = () => (from a in session.Query().OfType() where a.Pregnant select a.Id); - var nhOfType1 = new NhLinqExpression(ofType1.Body, sessions); - var nhOfType2 = new NhLinqExpression(ofType2.Body, sessions); + var nhOfType1 = new NhLinqExpression(ofType1.Body, Sfi); + var nhOfType2 = new NhLinqExpression(ofType2.Body, Sfi); Assert.AreNotEqual(nhOfType1.Key, nhOfType2.Key); } @@ -223,9 +223,9 @@ public void Different_Null_Returns_Different_Keys() Expression> null2 = () => (from a in session.Query() where a.Description == nullVariable select a); Expression> notNull = () => (from a in session.Query() where a.Description == notNullVariable select a); - var nhNull1 = new NhLinqExpression(null1.Body, sessions); - var nhNull2 = new NhLinqExpression(null2.Body, sessions); - var nhNotNull = new NhLinqExpression(notNull.Body, sessions); + var nhNull1 = new NhLinqExpression(null1.Body, Sfi); + var nhNull2 = new NhLinqExpression(null2.Body, Sfi); + var nhNotNull = new NhLinqExpression(notNull.Body, Sfi); Assert.AreNotEqual(nhNull1.Key, nhNotNull.Key); Assert.AreNotEqual(nhNull2.Key, nhNotNull.Key); diff --git a/src/NHibernate.Test/NHSpecificTest/CollectionFixture.cs b/src/NHibernate.Test/NHSpecificTest/CollectionFixture.cs index d7d7ef737fe..ebe24a0164c 100644 --- a/src/NHibernate.Test/NHSpecificTest/CollectionFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/CollectionFixture.cs @@ -18,7 +18,7 @@ protected override IList Mappings protected override void OnTearDown() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Delete("from LLParent"); session.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/CriteriaFromHql/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/CriteriaFromHql/Fixture.cs index 49419cf5ab2..8e240b5b718 100644 --- a/src/NHibernate.Test/NHSpecificTest/CriteriaFromHql/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/CriteriaFromHql/Fixture.cs @@ -26,7 +26,7 @@ public void UsingCriteriaAndHql() CreateData(); using (SqlLogSpy spy = new SqlLogSpy()) - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { Person result = session.CreateQuery(@" @@ -42,7 +42,7 @@ join fetch c.Children gc } using (SqlLogSpy spy = new SqlLogSpy()) - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { Person result = session.CreateCriteria(typeof(Person)) @@ -60,7 +60,7 @@ join fetch c.Children gc private void DeleteData() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Delete("from Person"); @@ -70,7 +70,7 @@ private void DeleteData() private void CreateData() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { Person root = new Person(); diff --git a/src/NHibernate.Test/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs index 92546865588..58dc8a857fe 100644 --- a/src/NHibernate.Test/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/CriteriaQueryOnComponentCollection/Fixture.cs @@ -18,7 +18,7 @@ protected override void Configure(Configuration configuration) protected override void OnSetUp() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (s.BeginTransaction()) { var parent = new Employee @@ -51,7 +51,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (s.BeginTransaction()) { s.Delete("from System.Object"); @@ -63,7 +63,7 @@ protected override void OnTearDown() [Test] public void CanQueryByCriteriaOnSetOfCompositeElement() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var list = s.CreateCriteria() .CreateCriteria("ManagedEmployees") @@ -80,7 +80,7 @@ public void CanQueryByCriteriaOnSetOfCompositeElement() [Test] public void CanQueryByCriteriaOnSetOfElement() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var list = s.CreateCriteria() .CreateCriteria("Amounts") @@ -99,7 +99,7 @@ public void CanQueryByCriteriaOnSetOfElement() [TestCase(JoinType.InnerJoin)] public void CanQueryByCriteriaOnSetOfElementByCreateAlias(JoinType joinType) { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var list = s.CreateCriteria("x") .CreateAlias("x.Amounts", "amount", joinType) @@ -117,7 +117,7 @@ public void CanQueryByCriteriaOnSetOfElementByCreateAlias(JoinType joinType) [Test] public void CanQueryByCriteriaOnSetOfCompositeElement_UsingDetachedCriteria() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var list = s.CreateCriteria() .Add(Subqueries.PropertyIn("id", diff --git a/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs b/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs index 5f47d850261..f6f55a0497e 100644 --- a/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs @@ -64,7 +64,7 @@ private void BeforeBindMapping(object sender, BindMappingEventArgs e) public void WillNotCrashOnDtcPrepareFailure() { var tx = new TransactionScope(); - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { s.Save(new Person {NotNullData = null}); // Cause a SQL not null constraint violation. } @@ -91,7 +91,7 @@ public void Can_roll_back_transaction() Assert.Ignore("Firebird driver does not support distributed transactions"); var tx = new TransactionScope(); - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { new ForceEscalationToDistributedTx(true); //will rollback tx s.Save(new Person { CreatedAt = DateTime.Today }); @@ -120,7 +120,7 @@ public void RollbackOutsideNh() { using (var txscope = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { var person = new Person { CreatedAt = DateTime.Now }; s.Save(person); @@ -150,7 +150,7 @@ public void TransactionInsertWithRollBackTask() { using (var txscope = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { var person = new Person {CreatedAt = DateTime.Now}; s.Save(person); @@ -178,7 +178,7 @@ public void TransactionInsertLoadWithRollBackTask() object savedId; using (var txscope = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { var person = new Person {CreatedAt = DateTime.Now}; savedId = s.Save(person); @@ -189,7 +189,7 @@ public void TransactionInsertLoadWithRollBackTask() { using (var txscope = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { var person = s.Get(savedId); person.CreatedAt = DateTime.Now; @@ -211,7 +211,7 @@ public void TransactionInsertLoadWithRollBackTask() { using (var txscope = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { var person = s.Get(savedId); s.Delete(person); @@ -266,7 +266,7 @@ public void CanDeleteItemInDtc() object id; using (var tx = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { id = s.Save(new Person {CreatedAt = DateTime.Today}); @@ -278,7 +278,7 @@ public void CanDeleteItemInDtc() using (var tx = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { new ForceEscalationToDistributedTx(); @@ -295,12 +295,12 @@ public void NH1744() { using (var tx = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { s.Flush(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { s.Flush(); } diff --git a/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs b/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs index 6ff4df8bf58..6704e5877be 100644 --- a/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/EmptyMappingsFixture.cs @@ -61,13 +61,13 @@ public void InvalidQuery() public void NullInterceptor() { IInterceptor nullInterceptor = null; - Assert.Throws(() => sessions.WithOptions().Interceptor(nullInterceptor).OpenSession().Close()); + Assert.Throws(() => Sfi.WithOptions().Interceptor(nullInterceptor).OpenSession().Close()); } [Test] public void DisconnectShouldNotCloseUserSuppliedConnection() { - var conn = sessions.ConnectionProvider.GetConnection(); + var conn = Sfi.ConnectionProvider.GetConnection(); try { using (ISession s = OpenSession()) @@ -80,7 +80,7 @@ public void DisconnectShouldNotCloseUserSuppliedConnection() } finally { - sessions.ConnectionProvider.CloseConnection(conn); + Sfi.ConnectionProvider.CloseConnection(conn); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs index abd7da5f0d8..8196a5ffe48 100644 --- a/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs @@ -15,7 +15,7 @@ public override string BugNumber protected override void OnSetUp() { base.OnSetUp(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var tx = session.BeginTransaction()) { session.Save(new Employee @@ -30,7 +30,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var tx = session.BeginTransaction()) { session.Delete(session.Load(1)); @@ -44,7 +44,7 @@ protected override void OnTearDown() [Test] public void Can_evict_entity_from_session() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var tx = session.BeginTransaction()) { var employee = session.Load(1); @@ -62,7 +62,7 @@ public void Can_evict_entity_from_session() public void Can_evict_non_persistent_object() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var tx = session.BeginTransaction()) { var employee = new Employee(); @@ -80,11 +80,11 @@ public void Can_evict_non_persistent_object() public void Can_evict_when_trying_to_evict_entity_from_another_session() { - using (var session1 = sessions.OpenSession()) + using (var session1 = Sfi.OpenSession()) using (var tx1 = session1.BeginTransaction()) { - using (var session2 = sessions.OpenSession()) + using (var session2 = Sfi.OpenSession()) using (var tx2 = session2.BeginTransaction()) { var employee = session2.Load(1); diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs index 000ca0710b4..224f44f8f0c 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FallbackFixture.cs @@ -47,7 +47,7 @@ protected override void Configure(Configuration configuration) protected override void OnTearDown() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { session.Delete("from Person"); session.Flush(); @@ -59,7 +59,7 @@ protected override void OnTearDown() [Test] public void FutureOfCriteriaFallsBackToListImplementationWhenQueryBatchingIsNotSupported() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var results = session.CreateCriteria().Future(); results.GetEnumerator().MoveNext(); @@ -71,7 +71,7 @@ public void FutureValueOfCriteriaCanGetSingleEntityWhenQueryBatchingIsNotSupport { int personId = CreatePerson(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var futurePerson = session.CreateCriteria() .Add(Restrictions.Eq("Id", personId)) @@ -85,7 +85,7 @@ public void FutureValueOfCriteriaCanGetScalarValueWhenQueryBatchingIsNotSupporte { CreatePerson(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var futureCount = session.CreateCriteria() .SetProjection(Projections.RowCount()) @@ -97,7 +97,7 @@ public void FutureValueOfCriteriaCanGetScalarValueWhenQueryBatchingIsNotSupporte [Test] public void FutureOfQueryFallsBackToListImplementationWhenQueryBatchingIsNotSupported() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var results = session.CreateQuery("from Person").Future(); results.GetEnumerator().MoveNext(); @@ -109,7 +109,7 @@ public void FutureValueOfQueryCanGetSingleEntityWhenQueryBatchingIsNotSupported( { int personId = CreatePerson(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var futurePerson = session.CreateQuery("from Person where Id = :id") .SetInt32("id", personId) @@ -123,7 +123,7 @@ public void FutureValueOfQueryCanGetScalarValueWhenQueryBatchingIsNotSupported() { CreatePerson(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var futureCount = session.CreateQuery("select count(*) from Person") .FutureValue(); @@ -134,7 +134,7 @@ public void FutureValueOfQueryCanGetScalarValueWhenQueryBatchingIsNotSupported() [Test] public void FutureOfLinqFallsBackToListImplementationWhenQueryBatchingIsNotSupported() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var results = session.Query().ToFuture(); results.GetEnumerator().MoveNext(); @@ -146,7 +146,7 @@ public void FutureValueOfLinqCanGetSingleEntityWhenQueryBatchingIsNotSupported() { var personId = CreatePerson(); - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var futurePerson = session.Query() .Where(x => x.Id == personId) @@ -157,7 +157,7 @@ public void FutureValueOfLinqCanGetSingleEntityWhenQueryBatchingIsNotSupported() private int CreatePerson() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var person = new Person(); session.Save(person); diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs index c148898e872..ddb3d5e3aa5 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs @@ -12,7 +12,7 @@ public class FutureCriteriaFixture : FutureFixture public void DefaultReadOnlyTest() { //NH-3575 - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.DefaultReadOnly = true; @@ -25,7 +25,7 @@ public void DefaultReadOnlyTest() [Test] public void CanUseFutureCriteria() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -57,7 +57,7 @@ public void CanUseFutureCriteria() [Test] public void TwoFuturesRunInTwoRoundTrips() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -84,7 +84,7 @@ public void TwoFuturesRunInTwoRoundTrips() [Test] public void CanCombineSingleFutureValueWithEnumerableFutures() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FutureFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FutureFixture.cs index 0d1ed25ad80..62b4d39a9ee 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FutureFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FutureFixture.cs @@ -20,7 +20,7 @@ protected override string MappingsAssembly protected void IgnoreThisTestIfMultipleQueriesArentSupportedByDriver() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (driver.SupportsMultipleQueries == false) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); } diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs index fae07d67097..803494498c7 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs @@ -14,7 +14,7 @@ public class FutureQueryFixture : FutureFixture public void DefaultReadOnlyTest() { //NH-3575 - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.DefaultReadOnly = true; @@ -27,7 +27,7 @@ public void DefaultReadOnlyTest() [Test] public void CanUseFutureQuery() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -59,7 +59,7 @@ public void CanUseFutureQuery() [Test] public void TwoFuturesRunInTwoRoundTrips() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -86,7 +86,7 @@ public void TwoFuturesRunInTwoRoundTrips() [Test] public void CanCombineSingleFutureValueWithEnumerableFutures() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -114,7 +114,7 @@ public void CanCombineSingleFutureValueWithEnumerableFutures() [Test] public void CanExecuteMultipleQueryWithSameParameterName() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs index 3a2f8ac184a..0daf83359a2 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryOverFixture.cs @@ -35,7 +35,7 @@ protected override void OnTearDown() public void DefaultReadOnlyTest() { //NH-3575 - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.DefaultReadOnly = true; @@ -48,7 +48,7 @@ public void DefaultReadOnlyTest() [Test] public void CanUseFutureCriteria() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -82,7 +82,7 @@ public void CanUseFutureCriteria() [Test] public void TwoFuturesRunInTwoRoundTrips() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); @@ -110,7 +110,7 @@ public void TwoFuturesRunInTwoRoundTrips() [Test] public void CanCombineSingleFutureValueWithEnumerableFutures() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); diff --git a/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs b/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs index 665b43c42f9..45e2de9782c 100644 --- a/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Futures/LinqFutureFixture.cs @@ -12,7 +12,7 @@ public class LinqFutureFixture : FutureFixture public void DefaultReadOnlyTest() { //NH-3575 - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.DefaultReadOnly = true; @@ -56,7 +56,7 @@ public void CoalesceShouldWorkForFutures() [Test] public void CanUseToFutureWithContains() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var ids = new[] { 1, 2, 3 }; var persons10 = s.Query() @@ -73,7 +73,7 @@ public void CanUseToFutureWithContains() [Test] public void CanUseToFutureWithContains2() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var ids = new[] { 1, 2, 3 }; var persons10 = s.Query() @@ -90,7 +90,7 @@ public void CanUseSkipAndFetchManyWithToFuture() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (var tx = s.BeginTransaction()) { var p1 = new Person { Name = "Parent" }; @@ -103,7 +103,7 @@ public void CanUseSkipAndFetchManyWithToFuture() s.Clear(); // we don't want caching } - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var persons10 = s.Query() .FetchMany(p => p.Children) @@ -138,7 +138,7 @@ public void CanUseFutureQuery() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var persons10 = s.Query() .Take(10) @@ -168,7 +168,7 @@ public void CanUseFutureQueryWithAnonymousType() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var persons = s.Query() .Select(p => new { Id = p.Id, Name = p.Name }) @@ -194,7 +194,7 @@ public void CanUseFutureFetchQuery() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (var tx = s.BeginTransaction()) { var p1 = new Person { Name = "Parent" }; @@ -207,7 +207,7 @@ public void CanUseFutureFetchQuery() s.Clear(); // we don't want caching } - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var persons = s.Query() .FetchMany(p => p.Children) @@ -241,7 +241,7 @@ public void TwoFuturesRunInTwoRoundTrips() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { using (var logSpy = new SqlLogSpy()) { @@ -268,7 +268,7 @@ public void CanCombineSingleFutureValueWithEnumerableFutures() { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var persons = s.Query() .Take(10) @@ -308,7 +308,7 @@ public void CanCombineSingleFutureValueWithFetchMany() tx.Commit(); } - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var meContainer = s.Query() .Where(x => x.Id == personId) @@ -329,7 +329,7 @@ public void CanCombineSingleFutureValueWithFetchMany() [Test] public void CanExecuteMultipleQueriesOnSameExpression() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { IgnoreThisTestIfMultipleQueriesArentSupportedByDriver(); diff --git a/src/NHibernate.Test/NHSpecificTest/GetTest.cs b/src/NHibernate.Test/NHSpecificTest/GetTest.cs index 2b6a97ca171..6ce161b10ed 100644 --- a/src/NHibernate.Test/NHSpecificTest/GetTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/GetTest.cs @@ -19,7 +19,7 @@ protected override IList Mappings protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/HqlOnMapWithForumula/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/HqlOnMapWithForumula/Fixture.cs index c1937ce2a0b..ab821f91533 100644 --- a/src/NHibernate.Test/NHSpecificTest/HqlOnMapWithForumula/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/HqlOnMapWithForumula/Fixture.cs @@ -17,7 +17,7 @@ public override string BugNumber [Test] public void TestBug() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.CreateQuery("from A a where 1 in elements(a.MyMaps)") .List(); diff --git a/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs b/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs index b76d3654f46..b16ba8f4140 100644 --- a/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/LazyLoadBugTest.cs @@ -84,7 +84,7 @@ public void TestLazyLoadNoAdd() Assert.AreEqual(1, parent2.ChildrenNoAdd.Count); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Delete("from LLParent"); session.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs index 2cdd424b97a..db7689f5c6c 100644 --- a/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/LoadingNullEntityInSet/Fixture.cs @@ -21,13 +21,13 @@ protected override string MappingsAssembly get { return "NHibernate.Test"; } } - protected override void BuildSessionFactory() + protected override DebugSessionFactory BuildSessionFactory() { cfg.GetCollectionMapping(typeof (Employee).FullName + ".Primaries") .CollectionTable.Name = "WantedProfessions"; cfg.GetCollectionMapping(typeof (Employee).FullName + ".Secondaries") .CollectionTable.Name = "WantedProfessions"; - base.BuildSessionFactory(); + return base.BuildSessionFactory(); } protected override void OnTearDown() diff --git a/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs b/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs index ce72e2099b6..aa62ff25f46 100644 --- a/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Logs/LogsFixture.cs @@ -34,7 +34,7 @@ public void WillGetSessionIdFromSessionLogs() ThreadContext.Properties["sessionId"] = new SessionIdCapturer(); using (var spy = new TextLogSpy("NHibernate.SQL", "%message | SessionId: %property{sessionId}")) - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var sessionId = ((SessionImpl)s).SessionId; diff --git a/src/NHibernate.Test/NHSpecificTest/MapFixture.cs b/src/NHibernate.Test/NHSpecificTest/MapFixture.cs index c56d80d48be..8a5d163d713 100644 --- a/src/NHibernate.Test/NHSpecificTest/MapFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/MapFixture.cs @@ -37,7 +37,7 @@ protected override bool AppliesTo(Dialect.Dialect dialect) protected override void OnTearDown() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Delete("from Team"); session.Delete("from Child"); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1001/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1001/Fixture.cs index f02049a6379..f67d8c64354 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1001/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1001/Fixture.cs @@ -47,7 +47,7 @@ public void Test() ExecuteStatement(string.Format("UPDATE EMPLOYEES SET DEPARTMENT_ID = 99999 WHERE EMPLOYEE_ID = {0}", employeeId)); - IStatistics stat = sessions.Statistics; + IStatistics stat = Sfi.Statistics; stat.Clear(); using (ISession sess = OpenSession()) using (ITransaction tx = sess.BeginTransaction()) diff --git a/src/NHibernate.Test/NHSpecificTest/NH1080/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1080/Fixture.cs index 63764453a40..d3d82ca4832 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1080/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1080/Fixture.cs @@ -58,7 +58,7 @@ public void TestBug() try { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Save(c); s.Save(b1); @@ -68,7 +68,7 @@ public void TestBug() s.Close(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { /* If bug is present, throws: NHibernate.Test.NHSpecificTest.NH1080.Fixture.TestBug : NHibernate.UnresolvableObjectException : No row with the given identifier exists: 1, of class: NHibernate.Test.NHSpecificTest.NH1080.B @@ -78,7 +78,7 @@ public void TestBug() } finally { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete(a); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1082/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1082/Fixture.cs index 31c961c8d6c..f2decaa583a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1082/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1082/Fixture.cs @@ -19,7 +19,7 @@ public void ExceptionsInBeforeTransactionCompletionAbortTransaction() var c = new C {ID = 1, Value = "value"}; var sessionInterceptor = new SessionInterceptorThatThrowsExceptionAtBeforeTransactionCompletion(); - using (var s = sessions.WithOptions().Interceptor(sessionInterceptor).OpenSession()) + using (var s = Sfi.WithOptions().Interceptor(sessionInterceptor).OpenSession()) using (var t = s.BeginTransaction()) { s.Save(c); @@ -27,7 +27,7 @@ public void ExceptionsInBeforeTransactionCompletionAbortTransaction() Assert.Throws(t.Commit); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { var objectInDb = s.Get(1); Assert.IsNull(objectInDb); @@ -41,7 +41,7 @@ public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransacti var c = new C { ID = 1, Value = "value" }; var synchronization = new SynchronizationThatThrowsExceptionAtBeforeTransactionCompletion(); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { t.RegisterSynchronization(synchronization); @@ -51,7 +51,7 @@ public void ExceptionsInSynchronizationBeforeTransactionCompletionAbortTransacti Assert.Throws(t.Commit); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { var objectInDb = s.Get(1); Assert.IsNull(objectInDb); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1093/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1093/Fixture.cs index ff00854c1db..555f3c68d54 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1093/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1093/Fixture.cs @@ -22,7 +22,7 @@ protected override string CacheConcurrencyStrategy private void Cleanup() { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { using (s.BeginTransaction()) { @@ -34,7 +34,7 @@ private void Cleanup() private void FillDb() { - using (ISession s = sessions.OpenSession()) + using (ISession s = OpenSession()) { using (ITransaction tx = s.BeginTransaction()) { @@ -80,13 +80,14 @@ private void NormalList() } } - protected override void BuildSessionFactory() + protected override DebugSessionFactory BuildSessionFactory() { // Without configured cache, should log warn. using (var ls = new LogSpy(LogManager.GetLogger(typeof(Fixture).Assembly, "NHibernate"), Level.Warn)) { - base.BuildSessionFactory(); + var factory = base.BuildSessionFactory(); Assert.That(ls.GetWholeLog(), Does.Contain("Fake cache used")); + return factory; } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1101/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1101/Fixture.cs index 8df1e1869d4..a4ee5fa2fc8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1101/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1101/Fixture.cs @@ -30,7 +30,7 @@ public void Behavior() { a = s.Get(savedId); - IStatistics statistics = sessions.Statistics; + IStatistics statistics = Sfi.Statistics; statistics.Clear(); Assert.IsNotNull(a.B); // an instance of B was created @@ -47,7 +47,7 @@ public void Behavior() { a = s.Load(savedId); - IStatistics statistics = sessions.Statistics; + IStatistics statistics = Sfi.Statistics; statistics.Clear(); Assert.IsNotNull(a.B); // an instance of B was created diff --git a/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs index ebfef06168d..cd45fe824b2 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs @@ -73,7 +73,7 @@ public void TestParametersWithTrailingNumbersMultipleInList() [Test] public void MultiQuerySingleInList() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs b/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs index 2d2dd4c1c82..0eeccfa3fd2 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1553/MsSQL/SnapshotIsolationUpdateConflictTest.cs @@ -66,7 +66,7 @@ public void UpdateConflictDetectedByNH() SavePerson(p1); Assert.That(p1.Version, Is.EqualTo(person.Version + 1)); - var expectedException = sessions.Settings.IsBatchVersionedDataEnabled + var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled ? (IResolveConstraint) Throws.InstanceOf() : Throws.InstanceOf() .And.Property("EntityName").EqualTo(typeof(Person).FullName) @@ -103,7 +103,7 @@ public void UpdateConflictDetectedBySQLServer() session2.SaveOrUpdate(p2); - var expectedException = sessions.Settings.IsBatchVersionedDataEnabled + var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled ? (IConstraint) Throws.InstanceOf() : Throws.InstanceOf() .And.Property("EntityName").EqualTo(typeof(Person).FullName) diff --git a/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs b/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs index 97b31bbff8e..859608a397b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs @@ -19,7 +19,7 @@ public void StatelessManyToOne() session.Flush(); } - using (IStatelessSession session = sessions.OpenStatelessSession()) + using (IStatelessSession session = Sfi.OpenStatelessSession()) { IQuery query = session.CreateQuery("from SpecializedPrincipal p"); IList principals = query.List(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs index e893a39190d..5fb0474b9f6 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs @@ -16,7 +16,7 @@ protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) [Test] public void Test() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (session.BeginTransaction()) { EntityA a1 = CreateEntityA(session); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs index e2094a6a4f4..8a82727e473 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1632/Fixture.cs @@ -28,7 +28,7 @@ public void When_using_DTC_HiLo_knows_to_create_isolated_DTC_transaction() { object scalar1, scalar2; - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var command = session.Connection.CreateCommand()) { command.CommandText = "select next_hi from hibernate_unique_key"; @@ -37,10 +37,10 @@ public void When_using_DTC_HiLo_knows_to_create_isolated_DTC_transaction() using (var tx = new TransactionScope()) { - var generator = sessions.GetIdentifierGenerator(typeof(Person).FullName); + var generator = Sfi.GetIdentifierGenerator(typeof(Person).FullName); Assert.That(generator, Is.InstanceOf()); - using(var session = sessions.OpenSession()) + using(var session = Sfi.OpenSession()) { var id = generator.Generate((ISessionImplementor) session, new Person()); } @@ -49,7 +49,7 @@ public void When_using_DTC_HiLo_knows_to_create_isolated_DTC_transaction() tx.Dispose(); } - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var command = session.Connection.CreateCommand()) { command.CommandText = "select next_hi from hibernate_unique_key"; @@ -66,7 +66,7 @@ public void Dispose_session_inside_transaction_scope() using (var tx = new TransactionScope()) { - using (s = sessions.OpenSession()) + using (s = Sfi.OpenSession()) { } @@ -82,7 +82,7 @@ public void When_commiting_items_in_DTC_transaction_will_add_items_to_2nd_level_ { using (var tx = new TransactionScope()) { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { s.Save(new Nums {ID = 29, NumA = 1, NumB = 3}); } @@ -91,7 +91,7 @@ public void When_commiting_items_in_DTC_transaction_will_add_items_to_2nd_level_ using (var tx = new TransactionScope()) { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var nums = s.Load(29); Assert.AreEqual(1, nums.NumA); @@ -101,12 +101,12 @@ public void When_commiting_items_in_DTC_transaction_will_add_items_to_2nd_level_ } //closing the connection to ensure we can't really use it. - var connection = sessions.ConnectionProvider.GetConnection(); - sessions.ConnectionProvider.CloseConnection(connection); + var connection = Sfi.ConnectionProvider.GetConnection(); + Sfi.ConnectionProvider.CloseConnection(connection); using (var tx = new TransactionScope()) { - using (var s = sessions.WithOptions().Connection(connection).OpenSession()) + using (var s = Sfi.WithOptions().Connection(connection).OpenSession()) { var nums = s.Load(29); Assert.AreEqual(1, nums.NumA); @@ -115,7 +115,7 @@ public void When_commiting_items_in_DTC_transaction_will_add_items_to_2nd_level_ tx.Complete(); } - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (var tx = s.BeginTransaction()) { var nums = s.Load(29); @@ -130,14 +130,14 @@ public void When_committing_transaction_scope_will_commit_transaction() object id; using (var tx = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { id = s.Save(new Nums { NumA = 1, NumB = 2, ID = 5 }); } tx.Complete(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Nums nums = s.Get(id); @@ -154,7 +154,7 @@ public void Will_not_save_when_flush_mode_is_never() object id; using (var tx = new TransactionScope()) { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.FlushMode = FlushMode.Manual; id = s.Save(new Nums { NumA = 1, NumB = 2, ID = 5 }); @@ -162,7 +162,7 @@ public void Will_not_save_when_flush_mode_is_never() tx.Complete(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Nums nums = s.Get(id); @@ -180,8 +180,8 @@ public void When_using_two_sessions_with_explicit_flush() object id1, id2; using (var tx = new TransactionScope()) { - using (ISession s1 = sessions.OpenSession()) - using (ISession s2 = sessions.OpenSession()) + using (ISession s1 = Sfi.OpenSession()) + using (ISession s2 = Sfi.OpenSession()) { id1 = s1.Save(new Nums { NumA = 1, NumB = 2, ID = 5 }); @@ -194,7 +194,7 @@ public void When_using_two_sessions_with_explicit_flush() } } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Nums nums = s.Get(id1); @@ -218,8 +218,8 @@ public void When_using_two_sessions() object id1, id2; using (var tx = new TransactionScope()) { - using (ISession s1 = sessions.OpenSession()) - using (ISession s2 = sessions.OpenSession()) + using (ISession s1 = Sfi.OpenSession()) + using (ISession s2 = Sfi.OpenSession()) { id1 = s1.Save(new Nums { NumA = 1, NumB = 2, ID = 5 }); @@ -230,7 +230,7 @@ public void When_using_two_sessions() } } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Nums nums = s.Get(id1); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs index 25c1223e659..c193889e84a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1640/Fixture.cs @@ -19,7 +19,7 @@ public void FetchJoinShouldNotReturnProxyTest() } } - using (IStatelessSession session = sessions.OpenStatelessSession()) + using (IStatelessSession session = Sfi.OpenStatelessSession()) { var parent = session.CreateQuery("from Entity p join fetch p.Child where p.Id=:pId").SetInt32("pId", savedId).UniqueResult diff --git a/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs index bbb82228e06..abd921e1f89 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1741/Fixture.cs @@ -100,7 +100,7 @@ public FlushMode FlushMode public void Bug() { var dq = new DetachedNamedQueryCrack(QueryName); - ISession s = sessions.OpenSession(); + ISession s = Sfi.OpenSession(); dq.GetExecutableQuery(s); s.Close(); @@ -121,7 +121,7 @@ public void Override() var dq = new DetachedNamedQueryCrack(QueryName); dq.SetCacheable(false).SetCacheRegion("another region").SetReadOnly(false).SetTimeout(20).SetCacheMode( CacheMode.Refresh).SetFetchSize(22).SetComment("another comment").SetFlushMode(FlushMode.Commit); - ISession s = sessions.OpenSession(); + ISession s = Sfi.OpenSession(); dq.GetExecutableQuery(s); s.Close(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs index 663f98a6fbe..b85d14b1570 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs @@ -9,9 +9,9 @@ public class Fixture: BugTestCase [Test] public void ColumnTypeBinaryBlob() { - var pc = sessions.GetEntityPersister(typeof (Document).FullName); + var pc = Sfi.GetEntityPersister(typeof (Document).FullName); var type = pc.GetPropertyType("Contents"); - Assert.That(type.SqlTypes(sessions)[0], Is.InstanceOf()); + Assert.That(type.SqlTypes(Sfi)[0], Is.InstanceOf()); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs index 31739a415f6..cbc62aa67ff 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs @@ -11,7 +11,7 @@ public class Fixture:BugTestCase { protected override void OnSetUp() { - sessions.Statistics.IsStatisticsEnabled = true; + Sfi.Statistics.IsStatisticsEnabled = true; using(ISession session=this.OpenSession()) using(ITransaction tran=session.BeginTransaction()) { @@ -38,7 +38,7 @@ protected override void OnTearDown() public void ExecutesOneQueryWithUniqueResultWithChildCriteriaNonGeneric() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession session = this.OpenSession()) { var criteria = session.CreateCriteria(typeof(Order),"o"); @@ -46,13 +46,13 @@ public void ExecutesOneQueryWithUniqueResultWithChildCriteriaNonGeneric() .Add(Restrictions.Eq("c.Id", 1)) .SetProjection(Projections.RowCount()) .UniqueResult(); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); } } [Test] public void ExecutesOneQueryWithUniqueResultWithChildCriteriaGeneric() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession session = this.OpenSession()) { session.CreateCriteria(typeof (Order), "o") @@ -60,32 +60,32 @@ public void ExecutesOneQueryWithUniqueResultWithChildCriteriaGeneric() .Add(Restrictions.Eq("c.Id", 1)) .SetProjection(Projections.RowCount()) .UniqueResult(); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); } } [Test] public void ExecutesOneQueryWithUniqueResultWithCriteriaNonGeneric() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession session = this.OpenSession()) { session.CreateCriteria(typeof (Order), "o") .SetProjection(Projections.RowCount()) .UniqueResult(); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); } } [Test] public void ExecutesOneQueryWithUniqueResultWithCriteriaGeneric() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession session = this.OpenSession()) { session.CreateCriteria(typeof (Order), "o") .SetProjection(Projections.RowCount()) .UniqueResult(); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); } } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs index 4fcc24800b8..6feb4958736 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1849/Fixture.cs @@ -46,7 +46,7 @@ public void ExecutesCustomSqlFunctionContains() { string hql = @"from Customer c where contains(c.Name, :smth)"; - HQLQueryPlan plan = new QueryExpressionPlan(new StringQueryExpression(hql), false, new CollectionHelper.EmptyMapClass(), sessions); + HQLQueryPlan plan = new QueryExpressionPlan(new StringQueryExpression(hql), false, new CollectionHelper.EmptyMapClass(), Sfi); Assert.AreEqual(1, plan.ParameterMetadata.NamedParameterNames.Count); Assert.AreEqual(1, plan.QuerySpaces.Count); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1869/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1869/Fixture.cs index 22e38b25929..d69c8a630d6 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1869/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1869/Fixture.cs @@ -16,7 +16,7 @@ protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) protected override void OnTearDown() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var transaction = session.BeginTransaction()) { session.Delete("from NodeKeyword"); @@ -29,7 +29,7 @@ protected override void OnTearDown() [Test] public void Test() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var transaction = session.BeginTransaction()) { _keyword = new Keyword(); @@ -43,7 +43,7 @@ public void Test() transaction.Commit(); } - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { //If uncomment the line below the test will pass //GetResult(session); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs index 4c90207d07d..c9f1f3e6da1 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1908ThreadSafety/Fixture.cs @@ -30,9 +30,9 @@ protected override void OnTearDown() // By clearing the connection pool the tables will get dropped. This is done by the following code. var fbConnectionType = ReflectHelper.TypeFromAssembly("FirebirdSql.Data.FirebirdClient.FbConnection", "FirebirdSql.Data.FirebirdClient", false); var clearPool = fbConnectionType.GetMethod("ClearPool"); - var sillyConnection = sessions.ConnectionProvider.GetConnection(); + var sillyConnection = Sfi.ConnectionProvider.GetConnection(); clearPool.Invoke(null, new object[] { sillyConnection }); - sessions.ConnectionProvider.CloseConnection(sillyConnection); + Sfi.ConnectionProvider.CloseConnection(sillyConnection); } [Test] @@ -72,7 +72,7 @@ public void UsingFiltersIsThreadSafe() private void ScenarioRunningWithMultiThreading() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { session .EnableFilter("CurrentOnly") diff --git a/src/NHibernate.Test/NHSpecificTest/NH1922/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1922/Fixture.cs index ae25e87a2cc..7c8cf920aa6 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1922/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1922/Fixture.cs @@ -39,7 +39,7 @@ protected override void OnTearDown() [Test] public void CanExecuteQueryOnStatelessSessionUsingDetachedCriteria() { - using(var stateless = sessions.OpenStatelessSession()) + using(var stateless = Sfi.OpenStatelessSession()) { var dc = DetachedCriteria.For() .Add(Restrictions.Eq("ValidUntil", new DateTime(2000,1,1))); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs index 69f6c070200..29ca75c4e3e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs @@ -17,11 +17,17 @@ protected override bool AppliesTo(ISessionFactoryImplementor factory) return factory.ConnectionProvider.Driver.SupportsMultipleQueries; } + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.Properties[Environment.CacheProvider] = typeof(HashtableCacheProvider).AssemblyQualifiedName; + configuration.Properties[Environment.UseQueryCache] = "true"; + } + protected override void OnSetUp() { - cfg.Properties[Environment.CacheProvider] = typeof(HashtableCacheProvider).AssemblyQualifiedName; - cfg.Properties[Environment.UseQueryCache] = "true"; - sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); + // Clear cache at each test. + RebuildSessionFactory(); } protected override void OnTearDown() diff --git a/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs b/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs index 7f4839c4a04..c1a6a0fc39e 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2031/HqlModFuctionForMsSqlTest.cs @@ -26,7 +26,7 @@ public void TheModuleOperationShouldAddParenthesisToAvoidWrongSentence() public string GetSql(string query) { - var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, sessions).Parse(), new CollectionHelper.EmptyMapClass(), sessions); + var qt = new QueryTranslatorImpl(null, new HqlParseEngine(query, false, Sfi).Parse(), new CollectionHelper.EmptyMapClass(), Sfi); qt.Compile(null, false); return qt.SQLString; } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2043/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2043/Fixture.cs index 3de94bcbf54..83bb483dda8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2043/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2043/Fixture.cs @@ -1,3 +1,4 @@ +using NHibernate.Cfg; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH2043 @@ -16,11 +17,11 @@ public override string GetEntityName(object entity) } } - protected override void BuildSessionFactory() - { - cfg.SetInterceptor(new Namer()); - base.BuildSessionFactory(); - } + protected override void Configure(Configuration configuration) + { + base.Configure(configuration); + configuration.SetInterceptor(new Namer()); + } [Test] public void Test() diff --git a/src/NHibernate.Test/NHSpecificTest/NH2055/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2055/Fixture.cs index cc5d247e4aa..5b9e70153ba 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2055/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2055/Fixture.cs @@ -25,7 +25,7 @@ protected override void Configure(Configuration configuration) [Test] public void CanCreateAndDropSchema() { - using(var s = sessions.OpenSession()) + using(var s = Sfi.OpenSession()) { using(var cmd = s.Connection.CreateCommand()) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs index b4665bc55a9..0ba0133fbdc 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2056/Fixture.cs @@ -20,7 +20,7 @@ protected override void OnTearDown() public void CanUpdateInheritedClass() { object savedId; - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var t = session.BeginTransaction()) { IDictionary address = new Dictionary(); @@ -32,7 +32,7 @@ public void CanUpdateInheritedClass() t.Commit(); } - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var t = session.BeginTransaction()) { var query = session.CreateQuery("Update Address address set address.AddressF1 = :val1, address.AddressF2 = :val2 where ID=:theID"); @@ -46,7 +46,7 @@ public void CanUpdateInheritedClass() t.Commit(); } - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var t = session.BeginTransaction()) { var updated = (IDictionary) session.Get("Address", savedId); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2111/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2111/Fixture.cs index 63bea9ce70f..9961e7ee80b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2111/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2111/Fixture.cs @@ -10,7 +10,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2112/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2112/Fixture.cs index 6d32c8b8b9e..a33f4759c86 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2112/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2112/Fixture.cs @@ -56,22 +56,22 @@ public void Test() } protected void ClearCounts() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); } protected void AssertInsertCount(long expected) { - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); } protected void AssertUpdateCount(int expected) { - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); } protected void AssertDeleteCount(int expected) { - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2118/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2118/Fixture.cs index e18ec73c69f..1080de9fa09 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2118/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2118/Fixture.cs @@ -18,7 +18,7 @@ protected override void OnSetUp() { base.OnSetUp(); - using(var s = sessions.OpenStatelessSession()) + using(var s = Sfi.OpenStatelessSession()) using(var tx = s.BeginTransaction()) { s.Insert(new Person {FirstName = "Bart", LastName = "Simpson"}); @@ -32,7 +32,7 @@ protected override void OnSetUp() [Test] public void CanGroupByWithoutSelect() { - using(var s = sessions.OpenSession()) + using(var s = Sfi.OpenSession()) using (s.BeginTransaction()) { var groups = s.Query().GroupBy(p => p.LastName).ToList(); @@ -44,7 +44,7 @@ public void CanGroupByWithoutSelect() protected override void OnTearDown() { base.OnTearDown(); - using(var s = sessions.OpenStatelessSession()) + using(var s = Sfi.OpenStatelessSession()) using (var tx = s.BeginTransaction()) { s.CreateQuery("delete from Person").ExecuteUpdate(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2189/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2189/Fixture.cs index 7518db7df67..fbecae9a506 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2189/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2189/Fixture.cs @@ -16,7 +16,7 @@ protected override void OnSetUp() { base.OnSetUp(); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { TeamMember tm1 = new TeamMember() { Name = "Joe" }; @@ -42,7 +42,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("FROM Task"); @@ -57,7 +57,7 @@ protected override void OnTearDown() [Test] public void FutureQueryReturnsExistingProxy() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { Policy policyProxy = s.Load(_policy2Id); @@ -77,7 +77,7 @@ public void FutureQueryReturnsExistingProxy() [Test] public void FutureCriteriaReturnsExistingProxy() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { Policy policyProxy = s.Load(_policy2Id); @@ -97,7 +97,7 @@ public void FutureCriteriaReturnsExistingProxy() [Test] public void FutureQueryEagerLoadUsesAlreadyLoadedEntity() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { Policy policy2 = s.CreateQuery("SELECT p FROM Policy p " + @@ -125,7 +125,7 @@ public void FutureQueryEagerLoadUsesAlreadyLoadedEntity() [Test] public void FutureCriteriaEagerLoadUsesAlreadyLoadedEntity() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { Policy policy2 = diff --git a/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs b/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs index 47339f77430..fbb9fa8cd75 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2195/SQLiteMultiCriteriaTest.cs @@ -94,7 +94,7 @@ public void SingleCriteriaQueriesWithStringsShouldExecuteCorrectly() [Test] public void MultiCriteriaQueriesWithIntsShouldExecuteCorrectly() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); @@ -123,7 +123,7 @@ public void MultiCriteriaQueriesWithIntsShouldExecuteCorrectly() [Test] public void MultiCriteriaQueriesWithStringsShouldExecuteCorrectly() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs index 6fd1328191f..bb1da07fcf8 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2203/Fixture.cs @@ -11,7 +11,7 @@ public class Fixture : BugTestCase protected override void OnSetUp() { base.OnSetUp(); - using (var session = sessions.OpenStatelessSession()) + using (var session = Sfi.OpenStatelessSession()) using (var tx = session.BeginTransaction()) { foreach (var artistName in new[] { "Foo", "Bar", "Baz", "Soz", "Tiz", "Fez" }) @@ -25,7 +25,7 @@ protected override void OnSetUp() [Test] public void QueryShouldWork() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using(session.BeginTransaction()) { var actual = session.Query() @@ -40,7 +40,7 @@ public void QueryShouldWork() protected override void OnTearDown() { - using(var session = sessions.OpenStatelessSession()) + using(var session = Sfi.OpenStatelessSession()) using (var tx = session.BeginTransaction()) { session.CreateQuery("delete Artist").ExecuteUpdate(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2218/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2218/Fixture.cs index 9d9ac1973ec..49b49b79d32 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2218/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2218/Fixture.cs @@ -61,7 +61,7 @@ public void SelectEntitiesByEntityName() [Test] public void SelectEntitiesByEntityNameFromStatelessSession() { - using (var session = sessions.OpenStatelessSession()) + using (var session = Sfi.OpenStatelessSession()) using (session.BeginTransaction()) { // verify the instance count for both mappings diff --git a/src/NHibernate.Test/NHSpecificTest/NH2244/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2244/Fixture.cs index 04175fee280..d1e0d9cb10f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2244/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2244/Fixture.cs @@ -13,7 +13,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2278/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2278/Fixture.cs index 60c974d5daf..d4f8c5bb11f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2278/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2278/Fixture.cs @@ -11,7 +11,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from CustomA" ); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2279/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2279/Fixture.cs index 0ca7e4ece77..6fdfe6ddf81 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2279/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2279/Fixture.cs @@ -11,7 +11,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs index 427039b096e..a952e4575a9 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2317/Fixture.cs @@ -10,7 +10,7 @@ public class Fixture : BugTestCase protected override void OnSetUp() { base.OnSetUp(); - using (var session = sessions.OpenStatelessSession()) + using (var session = Sfi.OpenStatelessSession()) using (var tx = session.BeginTransaction()) { foreach (var artistName in new[] { "Foo", "Bar", "Baz", "Soz", "Tiz", "Fez" }) @@ -24,7 +24,7 @@ protected override void OnSetUp() [Test] public void QueryShouldWork() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using(session.BeginTransaction()) { // The HQL : "select a.id from Artist a where a in (from Artist take 3)" @@ -40,7 +40,7 @@ public void QueryShouldWork() protected override void OnTearDown() { - using(var session = sessions.OpenStatelessSession()) + using(var session = Sfi.OpenStatelessSession()) using (var tx = session.BeginTransaction()) { session.CreateQuery("delete Artist").ExecuteUpdate(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2318/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2318/Fixture.cs index 9ec3d40fb96..b5f15a3194a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2318/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2318/Fixture.cs @@ -19,7 +19,7 @@ protected override void Configure(Cfg.Configuration configuration) protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete( "from A" ); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2392/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2392/Fixture.cs index 78c717883c3..c18b91a0ea9 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2392/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2392/Fixture.cs @@ -13,7 +13,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2394/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2394/Fixture.cs index 0e8e77d9331..428a5da633a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2394/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2394/Fixture.cs @@ -13,7 +13,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs index c0800a6f5c1..ca8e31a571a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2412/Fixture.cs @@ -13,7 +13,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from Order"); s.Delete("from Customer"); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs index e1bebdfea10..e868a7a8685 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2420/Fixture.cs @@ -65,7 +65,7 @@ public void ShouldBeAbleToReleaseSuppliedConnectionAfterDistributedTransaction() EnlistmentOptions.None); DbConnection connection; - if (sessions.ConnectionProvider.Driver.GetType() == typeof(OdbcDriver)) + if (Sfi.ConnectionProvider.Driver.GetType() == typeof(OdbcDriver)) connection = new OdbcConnection(connectionString); else connection = new SqlConnection(connectionString); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs index ecd9b0c71e7..5b9862c9dee 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2477/Fixture.cs @@ -57,7 +57,7 @@ public void WhenTakeBeforeCountShouldApplyTake() { using (new Scenario(Sfi)) { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (session.BeginTransaction()) { // This is another case where we have to work with subqueries and we have to write a specific query rewriter for Skip/Take instead flat the query in QueryReferenceExpressionFlattener diff --git a/src/NHibernate.Test/NHSpecificTest/NH2664/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2664/Fixture.cs index 55f3ae1c961..e3c5e4d9e2d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2664/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2664/Fixture.cs @@ -120,8 +120,8 @@ public void Different_Key_In_DynamicComponentDictionary_Returns_Different_Keys() Expression> key1 = () => (from a in session.Query() where a.Properties["Name"] == "val" select a); Expression> key2 = () => (from a in session.Query() where a.Properties["Description"] == "val" select a); - var nhKey1 = new NhLinqExpression(key1.Body, sessions); - var nhKey2 = new NhLinqExpression(key2.Body, sessions); + var nhKey1 = new NhLinqExpression(key1.Body, Sfi); + var nhKey2 = new NhLinqExpression(key2.Body, Sfi); Assert.AreNotEqual(nhKey1.Key, nhKey2.Key); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2721/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2721/Fixture.cs index 1a97e978315..1c130e92574 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2721/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2721/Fixture.cs @@ -11,7 +11,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using( ISession s = sessions.OpenSession() ) + using( ISession s = Sfi.OpenSession() ) { s.Delete("from A"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2812/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2812/Fixture.cs index 1982714b313..028bb1d2c59 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2812/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2812/Fixture.cs @@ -32,7 +32,7 @@ protected override void OnTearDown() [Test] public void PerformingAQueryOnAByteColumnShouldNotThrowEqualityOperator() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var query = (from e in session.Query() where e.ByteValue == 1 @@ -47,7 +47,7 @@ public void PerformingAQueryOnAByteColumnShouldNotThrowEqualityOperator() [Test] public void PerformingAQueryOnAByteColumnShouldNotThrowEquals() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) { var query = (from e in session.Query() where e.ByteValue.Equals(1) diff --git a/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs index 69aea993611..d48e948166d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2828/Fixture.cs @@ -14,7 +14,7 @@ public void WhenPersistShouldNotFetchUninitializedCollection() //Now in a second transaction i remove the address and persist Company: for a cascade option the Address will be removed using (var sl = new SqlLogSpy()) { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { using (ITransaction tx = session.BeginTransaction()) { @@ -37,7 +37,7 @@ public void WhenPersistShouldNotFetchUninitializedCollection() private void Cleanup(Guid companyId) { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { using (ITransaction tx = session.BeginTransaction()) { @@ -54,7 +54,7 @@ private Guid CreateScenario() var bankAccount = new BankAccount() {Name = "Bank test"}; company.AddAddress(address); company.AddBank(bankAccount); - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { using (ITransaction tx = session.BeginTransaction()) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2856/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2856/Fixture.cs index b4ce24c67e8..356d8acb57a 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2856/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2856/Fixture.cs @@ -45,21 +45,21 @@ public void EntityIsReturnedFromCacheOnSubsequentQueriesWhenUsingCacheableFetchQ .Fetch(p => p.Address) .Cacheable(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); var result = query.ToList(); // Execute the query Assert.That(result.Count, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(0)); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); var cachedResult = query.ToList(); // Re-execute the query Assert.That(cachedResult.Count, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(0)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(1)); } } diff --git a/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs index e94a53f9bdd..e64fe273a25 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2880/Fixture.cs @@ -12,7 +12,7 @@ public class Fixture : BugTestCase protected override void OnSetUp() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { using (ITransaction t = s.BeginTransaction()) { @@ -36,7 +36,7 @@ public void ProxiesFromDeserializedSessionsCanBeLoaded() { MemoryStream sessionMemoryStream; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { using (ITransaction t = s.BeginTransaction()) { @@ -66,7 +66,7 @@ public void EnabledFiltersStillHaveFilterDefinitionOnDeserializedSessions() { MemoryStream sessionMemoryStream; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.EnableFilter("myFilter"); @@ -86,7 +86,7 @@ public void EnabledFiltersStillHaveFilterDefinitionOnDeserializedSessions() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { using (ITransaction t = s.BeginTransaction()) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs index 8f448b5c75e..cdff9247ad9 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2898/Fixture.cs @@ -1,6 +1,5 @@ using NHibernate.Cfg; using NHibernate.Criterion; -using NHibernate.Engine; using NHibernate.Intercept; using NHibernate.Properties; using NUnit.Framework; @@ -10,12 +9,17 @@ namespace NHibernate.Test.NHSpecificTest.NH2898 [TestFixture] public class Fixture : BugTestCase { - protected override void OnSetUp() + protected override void Configure(Configuration configuration) { - cfg.Properties[Environment.CacheProvider] = typeof (BinaryFormatterCacheProvider).AssemblyQualifiedName; - cfg.Properties[Environment.UseQueryCache] = "true"; - sessions = (ISessionFactoryImplementor) cfg.BuildSessionFactory(); + base.Configure(configuration); + configuration.Properties[Environment.CacheProvider] = typeof(BinaryFormatterCacheProvider).AssemblyQualifiedName; + configuration.Properties[Environment.UseQueryCache] = "true"; + } + protected override void OnSetUp() + { + // Clear cache at each test. + RebuildSessionFactory(); using (var session = OpenSession()) using (var tx = session.BeginTransaction()) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH2985/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2985/Fixture.cs index e66ddd72de6..ca6efefeef7 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2985/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2985/Fixture.cs @@ -39,8 +39,8 @@ public void Test() } // Clear the cache - sessions.Evict(typeof (ClassA)); - sessions.Evict(typeof (WebImage)); + Sfi.Evict(typeof (ClassA)); + Sfi.Evict(typeof (WebImage)); using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) diff --git a/src/NHibernate.Test/NHSpecificTest/NH3050/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3050/Fixture.cs index 5c0f8ceaf06..8b315fe753f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3050/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3050/Fixture.cs @@ -61,7 +61,7 @@ public void Test() // get the planCache field on the QueryPlanCache and overwrite it with the restricted cache queryPlanCacheType .GetField("planCache", BindingFlags.Instance | BindingFlags.NonPublic) - .SetValue(sessions.QueryPlanCache, cache); + .SetValue(Sfi.QueryPlanCache, cache); // Initiate a LINQ query with a contains with one item in it, of which we know that the underlying IQueryExpression implementations // aka NhLinqExpression and the ExpandedQueryExpression generate the same key. @@ -82,7 +82,7 @@ public void Test() // This will constantly interact with the cache (Once in the PrepareQuery method of the DefaultQueryProvider and once in the Execute) System.Action queryExecutor = () => { - var sessionToUse = sessions.OpenSession(); + var sessionToUse = Sfi.OpenSession(); try { diff --git a/src/NHibernate.Test/NHSpecificTest/NH3050/FixtureByCode.cs b/src/NHibernate.Test/NHSpecificTest/NH3050/FixtureByCode.cs index b886168f562..bebb91c2c65 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3050/FixtureByCode.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3050/FixtureByCode.cs @@ -102,20 +102,20 @@ where names.Contains(e.Name) /// /// /// - private static bool TrySetQueryPlanCacheSize(NHibernate.ISessionFactory factory, int size) + private static bool TrySetQueryPlanCacheSize(ISessionFactory factory, int size) { - var factoryImpl = factory as NHibernate.Impl.SessionFactoryImpl; + var factoryImpl = (factory as DebugSessionFactory)?.ActualFactory as Impl.SessionFactoryImpl; if (factoryImpl != null) { - var queryPlanCacheFieldInfo = typeof(NHibernate.Impl.SessionFactoryImpl).GetField("queryPlanCache", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var queryPlanCacheFieldInfo = typeof(Impl.SessionFactoryImpl).GetField("queryPlanCache", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (queryPlanCacheFieldInfo != null) { - var queryPlanCache = (NHibernate.Engine.Query.QueryPlanCache)queryPlanCacheFieldInfo.GetValue(factoryImpl); + var queryPlanCache = (Engine.Query.QueryPlanCache)queryPlanCacheFieldInfo.GetValue(factoryImpl); - var planCacheFieldInfo = typeof(NHibernate.Engine.Query.QueryPlanCache).GetField("planCache", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); + var planCacheFieldInfo = typeof(Engine.Query.QueryPlanCache).GetField("planCache", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); if (planCacheFieldInfo != null) { - var softLimitMRUCache = new NHibernate.Util.SoftLimitMRUCache(size); + var softLimitMRUCache = new Util.SoftLimitMRUCache(size); planCacheFieldInfo.SetValue(queryPlanCache, softLimitMRUCache); return true; diff --git a/src/NHibernate.Test/NHSpecificTest/NH3058/SampleTest.cs b/src/NHibernate.Test/NHSpecificTest/NH3058/SampleTest.cs index 4438835d2e0..92e2994f147 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3058/SampleTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3058/SampleTest.cs @@ -1,5 +1,4 @@ using NHibernate.Context; -using NHibernate.Engine; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH3058 @@ -7,15 +6,6 @@ namespace NHibernate.Test.NHSpecificTest.NH3058 [TestFixture] public class SampleTest : BugTestCase { - public static ISessionFactoryImplementor AmbientSfi { get; private set; } - - protected override void BuildSessionFactory() - { - base.BuildSessionFactory(); - - AmbientSfi = Sfi; - } - protected override void Configure(Cfg.Configuration configuration) { base.Configure(configuration); diff --git a/src/NHibernate.Test/NHSpecificTest/NH3121/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3121/Fixture.cs index 16bb4da24f3..353d93e06fb 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3121/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3121/Fixture.cs @@ -27,7 +27,7 @@ public void ShouldThrowWhenByteArrayTooLong() // For SQL Server only the SqlClientDriver sets parameter lengths // even when there is no length specified in the mapping. The ODBC // driver won't cause the truncation issue and hence not the exception. - if (!(sessions.ConnectionProvider.Driver is SqlClientDriver)) + if (!(Sfi.ConnectionProvider.Driver is SqlClientDriver)) Assert.Ignore("Test limited to drivers that sets parameter length even with no length specified in the mapping."); const int reportSize = 17158; diff --git a/src/NHibernate.Test/NHSpecificTest/NH3234/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3234/Fixture.cs index a633e2dc40e..ad502dcf053 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3234/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3234/Fixture.cs @@ -9,7 +9,7 @@ public class Fixture : BugTestCase private void Evict(ISession session, GridWidget widget) { session.Evict(widget); - sessions.Evict(widget.GetType()); + Sfi.Evict(widget.GetType()); } private static void Save(ISession session, GridWidget widget) diff --git a/src/NHibernate.Test/NHSpecificTest/NH3436/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3436/Fixture.cs index 6fb23a02620..8552830b520 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3436/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3436/Fixture.cs @@ -98,7 +98,7 @@ public void TestQueryWithContains() private void Run(ICollection ids) { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (session.BeginTransaction()) { var result = session.Query() diff --git a/src/NHibernate.Test/NHSpecificTest/NH3505/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3505/Fixture.cs index 126a8b657a8..ef928a76835 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3505/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3505/Fixture.cs @@ -13,7 +13,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from Student"); s.Delete("from Teacher"); diff --git a/src/NHibernate.Test/NHSpecificTest/NH3518/XmlColumnTest.cs b/src/NHibernate.Test/NHSpecificTest/NH3518/XmlColumnTest.cs index d376c9cb359..832f8f30cb4 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3518/XmlColumnTest.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3518/XmlColumnTest.cs @@ -12,7 +12,7 @@ public class XmlColumnTest : BugTestCase { protected override void OnTearDown() { - using (var session = sessions.OpenSession()) + using (var session = Sfi.OpenSession()) using (var t = session.BeginTransaction()) { session.Delete("from ClassWithXmlMember"); @@ -43,7 +43,7 @@ public void FilteredQuery() xmlDocument.AppendChild(xmlElement); var parentA = new ClassWithXmlMember("A", xmlDocument); - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (var t = s.BeginTransaction()) { s.Save(parentA); diff --git a/src/NHibernate.Test/NHSpecificTest/NH3571/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3571/Fixture.cs index 10d0bb40f43..ed14712174f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3571/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3571/Fixture.cs @@ -124,8 +124,8 @@ public void DifferentKeyInDynamicComponentDictionaryReturnsDifferentExpressionKe Expression> key2 = () => (from a in session.Query() where (string) a.Details.Properties["Description"] == "val" select a); // ReSharper restore AccessToDisposedClosure - var nhKey1 = new NhLinqExpression(key1.Body, sessions); - var nhKey2 = new NhLinqExpression(key2.Body, sessions); + var nhKey1 = new NhLinqExpression(key1.Body, Sfi); + var nhKey2 = new NhLinqExpression(key2.Body, Sfi); Assert.AreNotEqual(nhKey1.Key, nhKey2.Key); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3771/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3771/Fixture.cs index 031cc8cfc72..efde4d3bbc4 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3771/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3771/Fixture.cs @@ -25,10 +25,10 @@ protected override bool AppliesTo(Engine.ISessionFactoryImplementor factory) [Description("Should be two batchs with two sentences each.")] public void InsertAndUpdateWithBatch() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (var sqlLog = new SqlLogSpy()) - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { Singer vs1 = new Singer(); @@ -71,7 +71,7 @@ public void InsertAndUpdateWithBatch() Assert.AreEqual(2, batchs); Assert.AreEqual(0, sqls); Assert.AreEqual(4, batchCommands); - Assert.AreEqual(2, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(2, Sfi.Statistics.PrepareStatementCount); tx.Rollback(); } diff --git a/src/NHibernate.Test/NHSpecificTest/NH3795/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3795/Fixture.cs index 17f559d6c13..c9fa894b04f 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3795/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3795/Fixture.cs @@ -21,7 +21,7 @@ protected override IList Mappings [Test] public void TestFieldAliasInQueryOver() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { A rowalias = null; s.QueryOver(() => AAliasField) @@ -35,7 +35,7 @@ public void TestFieldAliasInQueryOver() [Test] public void TestFieldAliasInQueryOverWithConversion() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { B rowalias = null; s.QueryOver(() => AAliasField) @@ -49,7 +49,7 @@ public void TestFieldAliasInQueryOverWithConversion() [Test] public void TestFieldAliasInJoinAlias() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { Child rowalias = null; s.QueryOver() @@ -64,7 +64,7 @@ public void TestFieldAliasInJoinAlias() [Test] public void TestFieldAliasInJoinQueryOver() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { Child rowalias = null; s.QueryOver() @@ -80,7 +80,7 @@ public void TestFieldAliasInJoinQueryOver() public void TestAliasInQueryOver() { A aAlias = null; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { A rowalias = null; s.QueryOver(() => aAlias) @@ -96,7 +96,7 @@ public void TestAliasInQueryOver() public void TestAliasInQueryOverWithConversion() { A aAlias = null; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { B rowalias = null; s.QueryOver(() => aAlias) @@ -112,7 +112,7 @@ public void TestAliasInJoinAlias() { Child childAlias = null; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { Child rowalias = null; s.QueryOver() @@ -129,7 +129,7 @@ public void TestAliasInJoinQueryOver() { Child childAlias = null; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { Child rowalias = null; s.QueryOver() diff --git a/src/NHibernate.Test/NHSpecificTest/NH392/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH392/Fixture.cs index 14ebd27506e..d26ced3d310 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH392/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH392/Fixture.cs @@ -37,7 +37,7 @@ public void UnsavedMinusOneNoNullReferenceException() protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from UnsavedValueMinusOne"); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH3932/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH3932/Fixture.cs index a81f7684b70..f9ab1822768 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH3932/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH3932/Fixture.cs @@ -189,7 +189,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { using (var tx = s.BeginTransaction()) { diff --git a/src/NHibernate.Test/NHSpecificTest/NH508/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH508/Fixture.cs index ec8a4bd64aa..0b62e484235 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH508/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH508/Fixture.cs @@ -27,7 +27,7 @@ public void Bug() object userId = null; - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tran = session.BeginTransaction()) { session.Save(friend1); @@ -38,7 +38,7 @@ public void Bug() } // reload the user and remove one of the 3 friends - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tran = session.BeginTransaction()) { User reloadedFriend = (User) session.Load(typeof(User), friend1.UserId); @@ -47,7 +47,7 @@ public void Bug() tran.Commit(); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { User admin = (User) session.Get(typeof(User), userId); diff --git a/src/NHibernate.Test/NHSpecificTest/NH687/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH687/Fixture.cs index 2b28c623fa4..843640e7c7d 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH687/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH687/Fixture.cs @@ -32,7 +32,7 @@ public void GetQueryTest() try { int child1Id, child2Id; - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Save(foo); @@ -41,7 +41,7 @@ public void GetQueryTest() session.Flush(); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { Foo r = session.Get(foo.Id); Assert.IsNotNull(r); diff --git a/src/NHibernate.Test/NHSpecificTest/NH719/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH719/Fixture.cs index 430ac9ff691..c0fb44f52aa 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH719/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH719/Fixture.cs @@ -21,7 +21,7 @@ public void CacheLoadTest() try { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Save(a); session.Save(b); @@ -31,7 +31,7 @@ public void CacheLoadTest() session.Flush(); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { // runs OK, since it's not cached NotCached nc = (NotCached) session.Load(typeof(NotCached), 1); @@ -43,7 +43,7 @@ public void CacheLoadTest() } // 2nd run fails, when data is read from the cache - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { // runs OK, since it's not cached NotCached nc = (NotCached) session.Load(typeof(NotCached), 1); diff --git a/src/NHibernate.Test/NHSpecificTest/NH734/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH734/Fixture.cs index 94658f454ee..468ba4f970b 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH734/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH734/Fixture.cs @@ -14,7 +14,7 @@ public override string BugNumber [TestAttribute] public void LimitProblem() { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { ICriteria criteria = session.CreateCriteria(typeof(MyClass)); criteria.SetMaxResults(100); diff --git a/src/NHibernate.Test/NHSpecificTest/NH750/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH750/Fixture.cs index eccd15558c8..b3b38396591 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH750/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH750/Fixture.cs @@ -8,7 +8,7 @@ public class Fixture : BugTestCase { protected override void OnTearDown() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete("from Device"); s.Delete("from Drive"); @@ -25,7 +25,7 @@ public void DeviceOfDrive() Drive dr3 = new Drive("Drive 3"); Device dv1 = new Device("Device 1"); Device dv2 = new Device("Device 2"); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Save(dr1); s.Save(dr2); @@ -39,7 +39,7 @@ public void DeviceOfDrive() dv1.Drives.Add(dr2); dv2.Drives.Add(dr1); dv2.Drives.Add(dr3); - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { dvSavedId[0] = (int) s.Save(dv1); dvSavedId[1] = (int) s.Save(dv2); @@ -47,7 +47,7 @@ public void DeviceOfDrive() } dv1 = null; dv2 = null; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.Delete(dr3); s.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH776/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH776/Fixture.cs index 52365afe2d7..3cbb9434761 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH776/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH776/Fixture.cs @@ -18,14 +18,14 @@ public void ProxiedOneToOneTest() try { - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { session.Save(a); session.Flush(); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) { A loadedA = (A) session.Load(typeof(A), 1); Assert.IsNull(loadedA.NotProxied); diff --git a/src/NHibernate.Test/NHSpecificTest/NH995/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH995/Fixture.cs index a9e5441e659..52c67546cd7 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH995/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH995/Fixture.cs @@ -55,9 +55,9 @@ public void Test() } // Clear the cache - sessions.Evict(typeof(ClassA)); - sessions.Evict(typeof(ClassB)); - sessions.Evict(typeof(ClassC)); + Sfi.Evict(typeof(ClassA)); + Sfi.Evict(typeof(ClassB)); + Sfi.Evict(typeof(ClassC)); using(ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) diff --git a/src/NHibernate.Test/NHSpecificTest/OptimisticConcurrencyFixture.cs b/src/NHibernate.Test/NHSpecificTest/OptimisticConcurrencyFixture.cs index 1bbabb628b9..896302ce411 100644 --- a/src/NHibernate.Test/NHSpecificTest/OptimisticConcurrencyFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/OptimisticConcurrencyFixture.cs @@ -56,7 +56,7 @@ public void StaleObjectStateCheckWithNormalizedEntityPersister() top.Name = "new name"; - var expectedException = sessions.Settings.IsBatchVersionedDataEnabled + var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled ? Throws.InstanceOf() : Throws.InstanceOf(); @@ -95,7 +95,7 @@ public void StaleObjectStateCheckWithEntityPersisterAndOptimisticLock() optimistic.String = "new string"; - var expectedException = sessions.Settings.IsBatchVersionedDataEnabled + var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled ? Throws.InstanceOf() : Throws.InstanceOf(); diff --git a/src/NHibernate.Test/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs index 109cd9df3c9..0d3d801dcff 100644 --- a/src/NHibernate.Test/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/SqlConverterAndMultiQuery/Fixture.cs @@ -28,7 +28,7 @@ public void NormalHqlShouldThrowUserException() [Test] public void MultiHqlShouldThrowUserException() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); @@ -57,7 +57,7 @@ public void NormalCriteriaShouldThrowUserException() [Test] public void MultiCriteriaShouldThrowUserException() { - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (!driver.SupportsMultipleQueries) Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName); diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index e20c21580a5..fbd40cd73ec 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -235,6 +235,7 @@ + diff --git a/src/NHibernate.Test/Naturalid/Immutable/ImmutableNaturalIdFixture.cs b/src/NHibernate.Test/Naturalid/Immutable/ImmutableNaturalIdFixture.cs index 3530ba5c0d2..5d1f6068fb0 100644 --- a/src/NHibernate.Test/Naturalid/Immutable/ImmutableNaturalIdFixture.cs +++ b/src/NHibernate.Test/Naturalid/Immutable/ImmutableNaturalIdFixture.cs @@ -89,7 +89,7 @@ public void NaturalIdCache() s.Transaction.Commit(); s.Close(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); s.BeginTransaction(); @@ -101,9 +101,9 @@ public void NaturalIdCache() s.Transaction.Commit(); s.Close(); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(1, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCachePutCount); s = OpenSession(); s.BeginTransaction(); @@ -112,7 +112,7 @@ public void NaturalIdCache() s.Transaction.Commit(); s.Close(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); s.BeginTransaction(); @@ -121,15 +121,15 @@ public void NaturalIdCache() s.CreateCriteria(typeof(User)).Add(Restrictions.NaturalId().Set("UserName", "steve")).SetCacheable(true). UniqueResult(); Assert.That(u, Is.Not.Null); - Assert.AreEqual(0, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(1, sessions.Statistics.QueryCacheHitCount); + Assert.AreEqual(0, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheHitCount); u = (User) s.CreateCriteria(typeof(User)).Add(Restrictions.NaturalId().Set("UserName", "steve")).SetCacheable(true). UniqueResult(); Assert.That(u, Is.Not.Null); - Assert.AreEqual(0, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(2, sessions.Statistics.QueryCacheHitCount); + Assert.AreEqual(0, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(2, Sfi.Statistics.QueryCacheHitCount); s.Transaction.Commit(); s.Close(); diff --git a/src/NHibernate.Test/Naturalid/Mutable/MutableNaturalIdFixture.cs b/src/NHibernate.Test/Naturalid/Mutable/MutableNaturalIdFixture.cs index 7aa9d921499..64cec2b5963 100644 --- a/src/NHibernate.Test/Naturalid/Mutable/MutableNaturalIdFixture.cs +++ b/src/NHibernate.Test/Naturalid/Mutable/MutableNaturalIdFixture.cs @@ -71,7 +71,7 @@ public void ReattachmentNaturalIdCheck() [Test] public void NonexistentNaturalIdCache() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); ISession s = OpenSession(); ITransaction t = s.BeginTransaction(); @@ -85,9 +85,9 @@ public void NonexistentNaturalIdCache() t.Commit(); s.Close(); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(0, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCachePutCount); s = OpenSession(); t = s.BeginTransaction(); @@ -98,7 +98,7 @@ public void NonexistentNaturalIdCache() t.Commit(); s.Close(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); t = s.BeginTransaction(); @@ -113,11 +113,11 @@ public void NonexistentNaturalIdCache() t.Commit(); s.Close(); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(1, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCachePutCount); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); t = s.BeginTransaction(); @@ -132,10 +132,10 @@ public void NonexistentNaturalIdCache() t.Commit(); s.Close(); - Assert.AreEqual(0, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(1, sessions.Statistics.QueryCacheHitCount); + Assert.AreEqual(0, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheHitCount); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); t = s.BeginTransaction(); @@ -149,9 +149,9 @@ public void NonexistentNaturalIdCache() t.Commit(); s.Close(); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(0, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCachePutCount); } [Test] @@ -166,7 +166,7 @@ public void NaturalIdCache() t.Commit(); s.Close(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); t = s.BeginTransaction(); @@ -180,9 +180,9 @@ public void NaturalIdCache() t.Commit(); s.Close(); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(1, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCachePutCount); s = OpenSession(); t = s.BeginTransaction(); @@ -193,7 +193,7 @@ public void NaturalIdCache() t.Commit(); s.Close(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); s = OpenSession(); t = s.BeginTransaction(); @@ -203,15 +203,15 @@ public void NaturalIdCache() .SetCacheable(true).UniqueResult(); Assert.That(u, Is.Not.Null); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); u = (User)s.CreateCriteria(typeof(User)) .Add(Restrictions.NaturalId().Set("name", "gavin").Set("org", "hb")) .SetCacheable(true).UniqueResult(); Assert.That(u, Is.Not.Null); - Assert.AreEqual(1, sessions.Statistics.QueryExecutionCount); - Assert.AreEqual(1, sessions.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryExecutionCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheHitCount); t.Commit(); s.Close(); diff --git a/src/NHibernate.Test/Ondelete/JoinedSubclassFixture.cs b/src/NHibernate.Test/Ondelete/JoinedSubclassFixture.cs index 9c5c8bbd6ec..1e489da5369 100644 --- a/src/NHibernate.Test/Ondelete/JoinedSubclassFixture.cs +++ b/src/NHibernate.Test/Ondelete/JoinedSubclassFixture.cs @@ -36,7 +36,7 @@ public void JoinedSubclassCascade() t.Commit(); s.Close(); - IStatistics statistics = sessions.Statistics; + IStatistics statistics = Sfi.Statistics; statistics.Clear(); s = OpenSession(); diff --git a/src/NHibernate.Test/Ondelete/OnDeleteFixture.cs b/src/NHibernate.Test/Ondelete/OnDeleteFixture.cs index b9bdc18997c..1e72def32ac 100644 --- a/src/NHibernate.Test/Ondelete/OnDeleteFixture.cs +++ b/src/NHibernate.Test/Ondelete/OnDeleteFixture.cs @@ -30,7 +30,7 @@ protected override bool AppliesTo(NHibernate.Dialect.Dialect dialect) [Test] public void JoinedSubclass() { - IStatistics statistics = sessions.Statistics; + IStatistics statistics = Sfi.Statistics; statistics.Clear(); ISession s = OpenSession(); diff --git a/src/NHibernate.Test/Ondelete/ParentChildFixture.cs b/src/NHibernate.Test/Ondelete/ParentChildFixture.cs index 97df7a0c596..56b7892402d 100644 --- a/src/NHibernate.Test/Ondelete/ParentChildFixture.cs +++ b/src/NHibernate.Test/Ondelete/ParentChildFixture.cs @@ -40,7 +40,7 @@ public void ParentChildCascade() t.Commit(); s.Close(); - IStatistics statistics = sessions.Statistics; + IStatistics statistics = Sfi.Statistics; statistics.Clear(); s = OpenSession(); diff --git a/src/NHibernate.Test/Operations/AbstractOperationTestCase.cs b/src/NHibernate.Test/Operations/AbstractOperationTestCase.cs index 684d9950812..0219e3d5432 100644 --- a/src/NHibernate.Test/Operations/AbstractOperationTestCase.cs +++ b/src/NHibernate.Test/Operations/AbstractOperationTestCase.cs @@ -36,22 +36,22 @@ protected override void Configure(Configuration configuration) protected void ClearCounts() { - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); } protected void AssertInsertCount(long expected) { - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(expected), "unexpected insert count"); } protected void AssertUpdateCount(int expected) { - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(expected), "unexpected update count"); } protected void AssertDeleteCount(int expected) { - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(expected), "unexpected delete count"); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/Operations/MergeFixture.cs b/src/NHibernate.Test/Operations/MergeFixture.cs index afa5ded161e..0ad89cce5de 100644 --- a/src/NHibernate.Test/Operations/MergeFixture.cs +++ b/src/NHibernate.Test/Operations/MergeFixture.cs @@ -257,7 +257,7 @@ public void MergeDeepTreeWithGeneratedId() AssertUpdateCount(1); ClearCounts(); - sessions.Evict(typeof (NumberedNode)); + Sfi.Evict(typeof (NumberedNode)); var child2 = new NumberedNode("child2"); var grandchild3 = new NumberedNode("grandchild3"); diff --git a/src/NHibernate.Test/ProjectionFixtures/Fixture.cs b/src/NHibernate.Test/ProjectionFixtures/Fixture.cs index a46e880dfa6..7ed54e43fc5 100644 --- a/src/NHibernate.Test/ProjectionFixtures/Fixture.cs +++ b/src/NHibernate.Test/ProjectionFixtures/Fixture.cs @@ -22,7 +22,7 @@ protected override string MappingsAssembly protected override void OnSetUp() { - using(var s = sessions.OpenSession()) + using(var s = Sfi.OpenSession()) using(var tx = s.BeginTransaction()) { var root = new TreeNode @@ -55,7 +55,7 @@ protected override void OnSetUp() protected override void OnTearDown() { - using(var s = sessions.OpenSession()) + using(var s = Sfi.OpenSession()) using (var tx = s.BeginTransaction()) { s.Delete("from TreeNode"); @@ -72,7 +72,7 @@ public void ErrorFromDBWillGiveTheActualSQLExecuted() Assert.Ignore( "Test checks for exact sql and expects an error to occur in a case which is not erroneous on all databases."); - string pName = ((ISqlParameterFormatter) sessions.ConnectionProvider.Driver).GetParameterName(0); + string pName = ((ISqlParameterFormatter) Sfi.ConnectionProvider.Driver).GetParameterName(0); string expectedMessagePart0 = string.Format("could not execute query" + Environment.NewLine + "[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = {0} ]", @@ -92,7 +92,7 @@ public void ErrorFromDBWillGiveTheActualSQLExecuted() var e = Assert.Throws(() => { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) using (var tx = s.BeginTransaction()) { var criteria = projection.GetExecutableCriteria(s); @@ -122,7 +122,7 @@ public void AggregatingHirearchyWithCount() .Add(Projections.Count(Projections.Property("grandchild.Key.Id"))) ); - using(var s = sessions.OpenSession()) + using(var s = Sfi.OpenSession()) using(var tx = s.BeginTransaction()) { var criteria = projection.GetExecutableCriteria(s); diff --git a/src/NHibernate.Test/QueryTest/MultiCriteriaFixture.cs b/src/NHibernate.Test/QueryTest/MultiCriteriaFixture.cs index 2bcf265f638..092281befe9 100644 --- a/src/NHibernate.Test/QueryTest/MultiCriteriaFixture.cs +++ b/src/NHibernate.Test/QueryTest/MultiCriteriaFixture.cs @@ -38,7 +38,7 @@ protected override void OnSetUp() { base.OnSetUp(); - this.sessions.Statistics.Clear(); + this.Sfi.Statistics.Clear(); } protected override void OnTearDown() @@ -122,7 +122,7 @@ public void CanExecuteMultiplyQueriesInSingleRoundTrip() [Test] public void CanUseSecondLevelCacheWithPositionalParameters() { - var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(Sfi); cacheHashtable.Clear(); CreateItems(); @@ -139,7 +139,7 @@ public void CanGetMultiQueryFromSecondLevelCache() //set the query in the cache DoMutiQueryAndAssert(); - var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(Sfi); var cachedListEntry = (IList)new ArrayList(cacheHashtable.Values)[0]; var cachedQuery = (IList)cachedListEntry[1]; @@ -151,7 +151,7 @@ public void CanGetMultiQueryFromSecondLevelCache() var secondQueryResults = (IList)cachedQuery[1]; secondQueryResults[0] = 2; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var criteria = s.CreateCriteria(typeof(Item)) .Add(Restrictions.Gt("id", 50)); @@ -173,14 +173,14 @@ public void CanUpdateStatisticsWhenGetMultiQueryFromSecondLevelCache() CreateItems(); DoMutiQueryAndAssert(); - Assert.AreEqual(0, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(1, sessions.Statistics.QueryCacheMissCount); - Assert.AreEqual(1, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(0, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheMissCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCachePutCount); DoMutiQueryAndAssert(); - Assert.AreEqual(1, sessions.Statistics.QueryCacheHitCount); - Assert.AreEqual(1, sessions.Statistics.QueryCacheMissCount); - Assert.AreEqual(1, sessions.Statistics.QueryCachePutCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheHitCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCacheMissCount); + Assert.AreEqual(1, Sfi.Statistics.QueryCachePutCount); } [Test] diff --git a/src/NHibernate.Test/QueryTest/MultipleMixedQueriesFixture.cs b/src/NHibernate.Test/QueryTest/MultipleMixedQueriesFixture.cs index 5eb674ec274..43f9d96d45e 100644 --- a/src/NHibernate.Test/QueryTest/MultipleMixedQueriesFixture.cs +++ b/src/NHibernate.Test/QueryTest/MultipleMixedQueriesFixture.cs @@ -38,7 +38,7 @@ protected override void OnTearDown() [Test] public void NH_1085_WillIgnoreParametersIfDoesNotAppearInQuery() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add(s.CreateSQLQuery("select * from ITEM where Id in (:ids)").AddEntity(typeof (Item))) @@ -52,7 +52,7 @@ public void NH_1085_WillIgnoreParametersIfDoesNotAppearInQuery() [Test] public void NH_1085_WillGiveReasonableErrorIfBadParameterName() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add(s.CreateSQLQuery("select * from ITEM where Id in (:ids)").AddEntity(typeof(Item))) @@ -69,7 +69,7 @@ public void CanGetMultiQueryFromSecondLevelCache() //set the query in the cache DoMutiQueryAndAssert(); - var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(Sfi); var cachedListEntry = (IList)new ArrayList(cacheHashtable.Values)[0]; var cachedQuery = (IList)cachedListEntry[1]; @@ -81,7 +81,7 @@ public void CanGetMultiQueryFromSecondLevelCache() var secondQueryResults = (IList)cachedQuery[1]; secondQueryResults[0] = 2L; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add(s.CreateSQLQuery("select * from ITEM where Id > ?").AddEntity(typeof(Item)) @@ -168,7 +168,7 @@ public void TwoMultiQueriesWithDifferentPagingGetDifferentResultsWhenUsingCached [Test] public void CanUseSecondLevelCacheWithPositionalParameters() { - var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(Sfi); cacheHashtable.Clear(); CreateItems(); diff --git a/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs b/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs index 81b43b066d6..7415e6ea043 100644 --- a/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs +++ b/src/NHibernate.Test/QueryTest/MultipleQueriesFixture.cs @@ -41,7 +41,7 @@ protected override void OnTearDown() [Test] public void NH_1085_WillIgnoreParametersIfDoesNotAppearInQuery() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add("from Item i where i.Id in (:ids)") @@ -55,7 +55,7 @@ public void NH_1085_WillIgnoreParametersIfDoesNotAppearInQuery() [Test] public void NH_1085_WillGiveReasonableErrorIfBadParameterName() { - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add("from Item i where i.Id in (:ids)") @@ -72,7 +72,7 @@ public void CanGetMultiQueryFromSecondLevelCache() //set the query in the cache DoMutiQueryAndAssert(); - var cacheHashtable = GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = GetHashTableUsedAsQueryCache(Sfi); var cachedListEntry = (IList)new ArrayList(cacheHashtable.Values)[0]; var cachedQuery = (IList)cachedListEntry[1]; @@ -84,7 +84,7 @@ public void CanGetMultiQueryFromSecondLevelCache() var secondQueryResults = (IList)cachedQuery[1]; secondQueryResults[0] = 2L; - using (var s = sessions.OpenSession()) + using (var s = Sfi.OpenSession()) { var multiQuery = s.CreateMultiQuery() .Add(s.CreateQuery("from Item i where i.Id > ?") @@ -170,7 +170,7 @@ public void TwoMultiQueriesWithDifferentPagingGetDifferentResultsWhenUsingCached [Test] public void CanUseSecondLevelCacheWithPositionalParameters() { - var cacheHashtable = GetHashTableUsedAsQueryCache(sessions); + var cacheHashtable = GetHashTableUsedAsQueryCache(Sfi); cacheHashtable.Clear(); CreateItems(); diff --git a/src/NHibernate.Test/QueryTest/NamedParametersFixture.cs b/src/NHibernate.Test/QueryTest/NamedParametersFixture.cs index dd2b46fe484..886e44491b4 100644 --- a/src/NHibernate.Test/QueryTest/NamedParametersFixture.cs +++ b/src/NHibernate.Test/QueryTest/NamedParametersFixture.cs @@ -45,7 +45,7 @@ public void TestMissingHQLParameters() [Test] public void TestNullNamedParameter() { - if (sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory) + if (Sfi.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory) { Assert.Ignore("Not supported; The AST parser can guess the type."); } diff --git a/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs b/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs index 04a9b314a7b..c555b096ce0 100644 --- a/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs +++ b/src/NHibernate.Test/ReadOnly/ReadOnlyCriteriaQueryTest.cs @@ -71,10 +71,10 @@ public void ModifiableSessionDefaultCriteria() t.Commit(); } - Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(4)); - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.EntityInsertCount, Is.EqualTo(4)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(0)); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession s = OpenSession()) using (ITransaction t = s.BeginTransaction()) @@ -119,10 +119,10 @@ public void ModifiableSessionDefaultCriteria() t.Commit(); } - Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(4)); + Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.EntityDeleteCount, Is.EqualTo(4)); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); } [Test] diff --git a/src/NHibernate.Test/SecondLevelCacheTest/QueryCacheFixture.cs b/src/NHibernate.Test/SecondLevelCacheTest/QueryCacheFixture.cs index 612553f587e..b1065393f3a 100644 --- a/src/NHibernate.Test/SecondLevelCacheTest/QueryCacheFixture.cs +++ b/src/NHibernate.Test/SecondLevelCacheTest/QueryCacheFixture.cs @@ -52,7 +52,7 @@ public void CleanUp() public void ShouldHitCacheUsingNamedQueryWithProjection() { FillDb(1); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) @@ -61,11 +61,11 @@ public void ShouldHitCacheUsingNamedQueryWithProjection() tx.Commit(); } - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCachePutCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCachePutCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(0)); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); using (ISession s = OpenSession()) using (ITransaction tx = s.BeginTransaction()) @@ -74,10 +74,10 @@ public void ShouldHitCacheUsingNamedQueryWithProjection() tx.Commit(); } - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(0)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(1)); - sessions.Statistics.LogSummary(); + Sfi.Statistics.LogSummary(); CleanUp(); } @@ -85,7 +85,7 @@ public void ShouldHitCacheUsingNamedQueryWithProjection() public void ShouldHitCacheUsingQueryWithProjection() { FillDb(1); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); int resultCount; using (ISession s = OpenSession()) @@ -97,11 +97,11 @@ public void ShouldHitCacheUsingQueryWithProjection() tx.Commit(); } - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCachePutCount, Is.EqualTo(1)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCachePutCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(0)); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); int secondResultCount; using (ISession s = OpenSession()) @@ -112,26 +112,26 @@ public void ShouldHitCacheUsingQueryWithProjection() tx.Commit(); } - Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(0)); - Assert.That(sessions.Statistics.QueryCacheHitCount, Is.EqualTo(1)); + Assert.That(Sfi.Statistics.QueryExecutionCount, Is.EqualTo(0)); + Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(1)); Assert.That(secondResultCount, Is.EqualTo(resultCount)); - sessions.Statistics.LogSummary(); + Sfi.Statistics.LogSummary(); CleanUp(); } [Test] public void QueryCacheInvalidation() { - sessions.EvictQueries(); - sessions.Statistics.Clear(); + Sfi.EvictQueries(); + Sfi.Statistics.Clear(); const string queryString = "from Item i where i.Name='widget'"; object savedId = CreateItem(queryString); - QueryStatistics qs = sessions.Statistics.GetQueryStatistics(queryString); - EntityStatistics es = sessions.Statistics.GetEntityStatistics(typeof(Item).FullName); + QueryStatistics qs = Sfi.Statistics.GetQueryStatistics(queryString); + EntityStatistics es = Sfi.Statistics.GetEntityStatistics(typeof(Item).FullName); Thread.Sleep(200); @@ -211,8 +211,8 @@ private object CreateItem(string queryString) public void SimpleProjections() { var transformer = new CustomTransformer(); - sessions.EvictQueries(); - sessions.Statistics.Clear(); + Sfi.EvictQueries(); + Sfi.Statistics.Clear(); const string queryString = "select i.Name, i.Description from AnotherItem i where i.Name='widget'"; @@ -226,8 +226,8 @@ public void SimpleProjections() tx.Commit(); } - QueryStatistics qs = sessions.Statistics.GetQueryStatistics(queryString); - EntityStatistics es = sessions.Statistics.GetEntityStatistics(typeof(AnotherItem).FullName); + QueryStatistics qs = Sfi.Statistics.GetQueryStatistics(queryString); + EntityStatistics es = Sfi.Statistics.GetEntityStatistics(typeof(AnotherItem).FullName); Thread.Sleep(200); diff --git a/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs b/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs index 4ed7f056d06..3b0b7f5d68d 100644 --- a/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs +++ b/src/NHibernate.Test/SecondLevelCacheTest/SecondLevelCacheTest.cs @@ -22,14 +22,19 @@ protected override IList Mappings get { return new string[] { "SecondLevelCacheTest.Item.hbm.xml" }; } } - protected override void OnSetUp() + protected override void Configure(Configuration configuration) { - cfg.Properties[Environment.CacheProvider] = typeof(HashtableCacheProvider).AssemblyQualifiedName; - cfg.Properties[Environment.UseQueryCache] = "true"; - sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); + base.Configure(configuration); + configuration.Properties[Environment.CacheProvider] = typeof(HashtableCacheProvider).AssemblyQualifiedName; + configuration.Properties[Environment.UseQueryCache] = "true"; + } + protected override void OnSetUp() + { + // Clear cache at each test. + RebuildSessionFactory(); using (ISession session = OpenSession()) - using(ITransaction tx = session.BeginTransaction()) + using (ITransaction tx = session.BeginTransaction()) { Item item = new Item(); item.Id = 1; @@ -46,15 +51,15 @@ protected override void OnSetUp() for (int i = 0; i < 5; i++) { AnotherItem obj = new AnotherItem("Item #" + i); - obj.Id = i+1; + obj.Id = i + 1; session.Save(obj); } tx.Commit(); } - sessions.Evict(typeof(Item)); - sessions.EvictCollection(typeof(Item).FullName + ".Children"); + Sfi.Evict(typeof(Item)); + Sfi.EvictCollection(typeof(Item).FullName + ".Children"); } protected override void OnTearDown() diff --git a/src/NHibernate.Test/SessionBuilder/Fixture.cs b/src/NHibernate.Test/SessionBuilder/Fixture.cs index 67184e6a697..fadeb1ba503 100644 --- a/src/NHibernate.Test/SessionBuilder/Fixture.cs +++ b/src/NHibernate.Test/SessionBuilder/Fixture.cs @@ -11,11 +11,7 @@ public class Fixture : TestCase { protected override string MappingsAssembly => "NHibernate.Test"; - protected override IList Mappings => - new string[] - { - "SessionBuilder.Mappings.hbm.xml" - }; + protected override IList Mappings => new [] { "SessionBuilder.Mappings.hbm.xml" }; protected override void Configure(Configuration configuration) { @@ -26,7 +22,7 @@ protected override void Configure(Configuration configuration) [Test] public void CanSetAutoClose() { - var sb = sessions.WithOptions(); + var sb = Sfi.WithOptions(); CanSetAutoClose(sb); using (var s = sb.OpenSession()) { @@ -36,7 +32,7 @@ public void CanSetAutoClose() private void CanSetAutoClose(T sb) where T : ISessionBuilder { - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); CanSet(sb, sb.AutoClose, () => options.ShouldAutoClose, sb is ISharedSessionBuilder ssb ? ssb.AutoClose : default(Func), // initial values @@ -48,7 +44,7 @@ private void CanSetAutoClose(T sb) where T : ISessionBuilder [Test] public void CanSetConnection() { - var sb = sessions.WithOptions(); + var sb = Sfi.WithOptions(); CanSetConnection(sb); using (var s = sb.OpenSession()) { @@ -59,10 +55,10 @@ public void CanSetConnection() private void CanSetConnection(T sb) where T : ISessionBuilder { var sbType = sb.GetType().Name; - var conn = sessions.ConnectionProvider.GetConnection(); + var conn = Sfi.ConnectionProvider.GetConnection(); try { - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); Assert.IsNull(options.UserSuppliedConnection, $"{sbType}: Initial value"); var fsb = sb.Connection(conn); Assert.AreEqual(conn, options.UserSuppliedConnection, $"{sbType}: After call with a connection"); @@ -96,19 +92,19 @@ private void CanSetConnection(T sb) where T : ISessionBuilder } finally { - sessions.ConnectionProvider.CloseConnection(conn); + Sfi.ConnectionProvider.CloseConnection(conn); } } [Test] public void CanSetConnectionOnStateless() { - var sb = sessions.WithStatelessOptions(); + var sb = Sfi.WithStatelessOptions(); var sbType = sb.GetType().Name; - var conn = sessions.ConnectionProvider.GetConnection(); + var conn = Sfi.ConnectionProvider.GetConnection(); try { - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); Assert.IsNull(options.UserSuppliedConnection, $"{sbType}: Initial value"); var fsb = sb.Connection(conn); Assert.AreEqual(conn, options.UserSuppliedConnection, $"{sbType}: After call with a connection"); @@ -120,14 +116,14 @@ public void CanSetConnectionOnStateless() } finally { - sessions.ConnectionProvider.CloseConnection(conn); + Sfi.ConnectionProvider.CloseConnection(conn); } } [Test] public void CanSetConnectionReleaseMode() { - var sb = sessions.WithOptions(); + var sb = Sfi.WithOptions(); CanSetConnectionReleaseMode(sb); using (var s = sb.OpenSession()) { @@ -137,11 +133,11 @@ public void CanSetConnectionReleaseMode() private void CanSetConnectionReleaseMode(T sb) where T : ISessionBuilder { - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); CanSet(sb, sb.ConnectionReleaseMode, () => options.SessionConnectionReleaseMode, sb is ISharedSessionBuilder ssb ? ssb.ConnectionReleaseMode : default(Func), // initial values - sessions.Settings.ConnectionReleaseMode, + Sfi.Settings.ConnectionReleaseMode, // values ConnectionReleaseMode.OnClose, ConnectionReleaseMode.AfterStatement, ConnectionReleaseMode.AfterTransaction); } @@ -149,7 +145,7 @@ private void CanSetConnectionReleaseMode(T sb) where T : ISessionBuilder [Test] public void CanSetFlushMode() { - var sb = sessions.WithOptions(); + var sb = Sfi.WithOptions(); CanSetFlushMode(sb); using (var s = sb.OpenSession()) { @@ -159,11 +155,11 @@ public void CanSetFlushMode() private void CanSetFlushMode(T sb) where T : ISessionBuilder { - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); CanSet(sb, sb.FlushMode, () => options.InitialSessionFlushMode, sb is ISharedSessionBuilder ssb ? ssb.FlushMode : default(Func), // initial values - sessions.Settings.DefaultFlushMode, + Sfi.Settings.DefaultFlushMode, // values FlushMode.Always, FlushMode.Auto, FlushMode.Commit, FlushMode.Manual); } @@ -171,7 +167,7 @@ private void CanSetFlushMode(T sb) where T : ISessionBuilder [Test] public void CanSetInterceptor() { - var sb = sessions.WithOptions(); + var sb = Sfi.WithOptions(); CanSetInterceptor(sb); using (var s = sb.OpenSession()) { @@ -184,9 +180,9 @@ private void CanSetInterceptor(T sb) where T : ISessionBuilder var sbType = sb.GetType().Name; // Do not use .Instance here, we want another instance. var interceptor = new EmptyInterceptor(); - var options = (ISessionCreationOptions)sb; + var options = DebugSessionFactory.GetCreationOptions(sb); - Assert.AreEqual(sessions.Interceptor, options.SessionInterceptor, $"{sbType}: Initial value"); + Assert.AreEqual(Sfi.Interceptor, options.SessionInterceptor, $"{sbType}: Initial value"); var fsb = sb.Interceptor(interceptor); Assert.AreEqual(interceptor, options.SessionInterceptor, $"{sbType}: After call with an interceptor"); Assert.AreEqual(sb, fsb, $"{sbType}: Unexpected fluent return after call with an interceptor"); diff --git a/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs b/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs index d73ef2dfac1..0d9dcafa038 100644 --- a/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs +++ b/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs @@ -40,9 +40,9 @@ public void HandSQL() t.Commit(); s.Close(); - sessions.Evict(typeof(Organization)); - sessions.Evict(typeof(Person)); - sessions.Evict(typeof(Employment)); + Sfi.Evict(typeof(Organization)); + Sfi.Evict(typeof(Person)); + Sfi.Evict(typeof(Employment)); s = OpenSession(); t = s.BeginTransaction(); diff --git a/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs b/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs index 6ce8d082bbe..e26957594c5 100644 --- a/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs +++ b/src/NHibernate.Test/Stateless/Fetching/StatelessSessionFetchingTest.cs @@ -41,7 +41,7 @@ public void DynamicFetch() tx.Commit(); } - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) using (ITransaction tx = ss.BeginTransaction()) { ss.BeginTransaction(); diff --git a/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs b/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs index f072ca15136..e4c808ab5ce 100644 --- a/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs +++ b/src/NHibernate.Test/Stateless/FetchingLazyCollections/LazyCollectionFetchTests.cs @@ -77,7 +77,7 @@ public void ShouldWorkLoadingComplexEntities() const string crocodileFather = "Crocodile father"; const string crocodileMother = "Crocodile mother"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var rf = new Reptile { Description = crocodileFather }; @@ -96,7 +96,7 @@ public void ShouldWorkLoadingComplexEntities() const string humanFather = "Fred"; const string humanMother = "Wilma"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var hf = new Human { Description = "Flinstone", Name = humanFather }; @@ -112,7 +112,7 @@ public void ShouldWorkLoadingComplexEntities() tx.Commit(); } - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) using (ITransaction tx = s.BeginTransaction()) { IList> hf = s.CreateQuery("from HumanFamily").List>(); @@ -130,7 +130,7 @@ public void ShouldWorkLoadingComplexEntities() tx.Commit(); } - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) using (ITransaction tx = s.BeginTransaction()) { IList> hf = s.Query>().FetchMany(f => f.Childs).ToList(); @@ -150,7 +150,7 @@ public void ShouldWorkLoadingComplexEntities() tx.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from HumanFamily"); diff --git a/src/NHibernate.Test/Stateless/FetchingLazyCollections/TreeFetchTests.cs b/src/NHibernate.Test/Stateless/FetchingLazyCollections/TreeFetchTests.cs index 8fc041724a3..4705bbe2d81 100644 --- a/src/NHibernate.Test/Stateless/FetchingLazyCollections/TreeFetchTests.cs +++ b/src/NHibernate.Test/Stateless/FetchingLazyCollections/TreeFetchTests.cs @@ -31,7 +31,7 @@ protected override HbmMapping GetMappings() [Test] public void FetchMultipleHierarchies() { - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var root = new TreeNode {Content = "Root"}; @@ -44,7 +44,7 @@ public void FetchMultipleHierarchies() tx.Commit(); } - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) using (ITransaction tx = s.BeginTransaction()) { IList rootNodes = s.Query().Where(t => t.Content == "Root") @@ -56,7 +56,7 @@ public void FetchMultipleHierarchies() tx.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from TreeNode"); diff --git a/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs b/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs index 207d1afe676..c120bfe8b9f 100644 --- a/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs +++ b/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs @@ -35,7 +35,7 @@ public void CreateUpdateReadDelete() Document doc; DateTime? initVersion; - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { ITransaction tx; using (tx = ss.BeginTransaction()) @@ -93,7 +93,7 @@ public void CreateUpdateReadDelete() [Test] public void HqlBulk() { - IStatelessSession ss = sessions.OpenStatelessSession(); + IStatelessSession ss = Sfi.OpenStatelessSession(); ITransaction tx = ss.BeginTransaction(); var doc = new Document("blah blah blah", "Blahs"); ss.Insert(doc); @@ -124,7 +124,7 @@ public void InitId() { Paper paper; - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { ITransaction tx; using (tx = ss.BeginTransaction()) @@ -147,7 +147,7 @@ public void Refresh() { Paper paper; - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { @@ -156,7 +156,7 @@ public void Refresh() tx.Commit(); } } - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { @@ -166,7 +166,7 @@ public void Refresh() tx.Commit(); } } - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { using (ITransaction tx = ss.BeginTransaction()) { @@ -185,7 +185,7 @@ public void WhenSetTheBatchSizeThenSetTheBatchSizeOfTheBatcher() if (!Dialect.SupportsSqlBatches) Assert.Ignore("Dialect does not support sql batches."); - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { ss.SetBatchSize(37); var impl = (ISessionImplementor)ss; @@ -196,7 +196,7 @@ public void WhenSetTheBatchSizeThenSetTheBatchSizeOfTheBatcher() [Test] public void CanGetImplementor() { - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { Assert.That(ss.GetSessionImplementation(), Is.SameAs(ss)); } @@ -206,7 +206,7 @@ public void CanGetImplementor() public void HavingDetachedCriteriaThenCanGetExecutableCriteriaFromStatelessSession() { var dc = DetachedCriteria.For(); - using (IStatelessSession ss = sessions.OpenStatelessSession()) + using (IStatelessSession ss = Sfi.OpenStatelessSession()) { ICriteria criteria = null; Assert.That(() => criteria = dc.GetExecutableCriteria(ss), Throws.Nothing); @@ -219,7 +219,7 @@ public void DisposingClosedStatelessSessionShouldNotCauseSessionException() { try { - IStatelessSession ss = sessions.OpenStatelessSession(); + IStatelessSession ss = Sfi.OpenStatelessSession(); ss.Close(); ss.Dispose(); } diff --git a/src/NHibernate.Test/Stateless/StatelessSessionQueryFixture.cs b/src/NHibernate.Test/Stateless/StatelessSessionQueryFixture.cs index 4d542db39af..562d0e56328 100644 --- a/src/NHibernate.Test/Stateless/StatelessSessionQueryFixture.cs +++ b/src/NHibernate.Test/Stateless/StatelessSessionQueryFixture.cs @@ -76,10 +76,10 @@ public virtual void cleanData() [Test] public void Criteria() { - var testData = new TestData(sessions); + var testData = new TestData(Sfi); testData.createData(); - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) { Assert.AreEqual(1, s.CreateCriteria().List().Count); } @@ -90,10 +90,10 @@ public void Criteria() [Test] public void CriteriaWithSelectFetchMode() { - var testData = new TestData(sessions); + var testData = new TestData(Sfi); testData.createData(); - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) { Assert.AreEqual(1, s.CreateCriteria().SetFetchMode("Org", FetchMode.Select).List().Count); } @@ -104,10 +104,10 @@ public void CriteriaWithSelectFetchMode() [Test] public void Hql() { - var testData = new TestData(sessions); + var testData = new TestData(Sfi); testData.createData(); - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) { Assert.AreEqual(1, s.CreateQuery("from Contact c join fetch c.Org join fetch c.Org.Country").List().Count); } diff --git a/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs b/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs index 86b55dd8db9..7307ae57d0f 100644 --- a/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs +++ b/src/NHibernate.Test/Stateless/StatelessWithRelationsFixture.cs @@ -23,7 +23,7 @@ public void ShouldWorkLoadingComplexEntities() const string crocodileFather = "Crocodile father"; const string crocodileMother = "Crocodile mother"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var rf = new Reptile { Description = crocodileFather }; @@ -42,7 +42,7 @@ public void ShouldWorkLoadingComplexEntities() const string humanFather = "Fred"; const string humanMother = "Wilma"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { var hf = new Human { Description = "Flinstone", Name = humanFather }; @@ -58,7 +58,7 @@ public void ShouldWorkLoadingComplexEntities() tx.Commit(); } - using (IStatelessSession s = sessions.OpenStatelessSession()) + using (IStatelessSession s = Sfi.OpenStatelessSession()) using (ITransaction tx = s.BeginTransaction()) { IList> hf = s.CreateQuery("from HumanFamily").List>(); @@ -78,7 +78,7 @@ public void ShouldWorkLoadingComplexEntities() tx.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction tx = s.BeginTransaction()) { s.Delete("from HumanFamily"); diff --git a/src/NHibernate.Test/Stats/SessionStatsFixture.cs b/src/NHibernate.Test/Stats/SessionStatsFixture.cs index 1f1c6d94708..c767b8a60a1 100644 --- a/src/NHibernate.Test/Stats/SessionStatsFixture.cs +++ b/src/NHibernate.Test/Stats/SessionStatsFixture.cs @@ -42,7 +42,7 @@ private static void CleanDb(ISession s) [Test] public void Can_use_cached_query_that_return_no_results() { - Assert.IsTrue(sessions.Settings.IsQueryCacheEnabled); + Assert.IsTrue(Sfi.Settings.IsQueryCacheEnabled); using(ISession s = OpenSession()) { @@ -70,7 +70,7 @@ public void SessionStatistics() { ISession s = OpenSession(); ITransaction tx = s.BeginTransaction(); - IStatistics stats = sessions.Statistics; + IStatistics stats = Sfi.Statistics; stats.Clear(); bool isStats = stats.IsStatisticsEnabled; stats.IsStatisticsEnabled = true; diff --git a/src/NHibernate.Test/Stats/StatsFixture.cs b/src/NHibernate.Test/Stats/StatsFixture.cs index cf0da699e31..1fe997dc6a2 100644 --- a/src/NHibernate.Test/Stats/StatsFixture.cs +++ b/src/NHibernate.Test/Stats/StatsFixture.cs @@ -47,7 +47,7 @@ private static void CleanDb(ISession s) [Test] public void CollectionFetchVsLoad() { - IStatistics stats = sessions.Statistics; + IStatistics stats = Sfi.Statistics; stats.Clear(); ISession s = OpenSession(); @@ -139,7 +139,7 @@ public void CollectionFetchVsLoad() [Test] public void QueryStatGathering() { - IStatistics stats = sessions.Statistics; + IStatistics stats = Sfi.Statistics; stats.Clear(); ISession s = OpenSession(); @@ -221,7 +221,7 @@ public void IncrementQueryExecutionCount_WhenExplicitQueryIsExecuted() tx.Commit(); } - IStatistics stats = sessions.Statistics; + IStatistics stats = Sfi.Statistics; stats.Clear(); using (ISession s = OpenSession()) { @@ -238,7 +238,7 @@ public void IncrementQueryExecutionCount_WhenExplicitQueryIsExecuted() stats.Clear(); - var driver = sessions.ConnectionProvider.Driver; + var driver = Sfi.ConnectionProvider.Driver; if (driver.SupportsMultipleQueries) { using (var s = OpenSession()) diff --git a/src/NHibernate.Test/SubselectFetchTest/SubselectFetchFixture.cs b/src/NHibernate.Test/SubselectFetchTest/SubselectFetchFixture.cs index 09a2b55642b..ae5dc462b87 100644 --- a/src/NHibernate.Test/SubselectFetchTest/SubselectFetchFixture.cs +++ b/src/NHibernate.Test/SubselectFetchTest/SubselectFetchFixture.cs @@ -34,7 +34,7 @@ public void SubselectFetchHql() s = OpenSession(); t = s.BeginTransaction(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); IList parents = s.CreateQuery("from Parent where name between 'bar' and 'foo' order by name desc") .List(); @@ -65,7 +65,7 @@ public void SubselectFetchHql() Assert.IsTrue(NHibernateUtil.IsInitialized(q.MoreChildren[0])); - Assert.AreEqual(3, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(3, Sfi.Statistics.PrepareStatementCount); Child c = (Child) p.Children[0]; NHibernateUtil.Initialize(c.Friends); @@ -97,7 +97,7 @@ public void SubselectFetchNamedParam() s = OpenSession(); t = s.BeginTransaction(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); IList parents = s.CreateQuery("from Parent where name between :bar and :foo order by name desc") .SetParameter("bar", "bar") @@ -130,7 +130,7 @@ public void SubselectFetchNamedParam() Assert.IsTrue(NHibernateUtil.IsInitialized(q.MoreChildren[0])); - Assert.AreEqual(3, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(3, Sfi.Statistics.PrepareStatementCount); Child c = (Child) p.Children[0]; NHibernateUtil.Initialize(c.Friends); @@ -162,7 +162,7 @@ public void SubselectFetchPosParam() s = OpenSession(); t = s.BeginTransaction(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); IList parents = s.CreateQuery("from Parent where name between ? and ? order by name desc") .SetParameter(0, "bar") @@ -195,7 +195,7 @@ public void SubselectFetchPosParam() Assert.IsTrue(NHibernateUtil.IsInitialized(q.MoreChildren[0])); - Assert.AreEqual(3, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(3, Sfi.Statistics.PrepareStatementCount); Child c = (Child) p.Children[0]; NHibernateUtil.Initialize(c.Friends); @@ -229,7 +229,7 @@ public void SubselectFetchWithLimit() s = OpenSession(); t = s.BeginTransaction(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); IList parents = s.CreateQuery("from Parent order by name desc") .SetMaxResults(2) @@ -245,7 +245,7 @@ public void SubselectFetchWithLimit() Assert.IsTrue(NHibernateUtil.IsInitialized(q.Children)); Assert.IsTrue(NHibernateUtil.IsInitialized(q.MoreChildren)); - Assert.AreEqual(3, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(3, Sfi.Statistics.PrepareStatementCount); r = (Parent) s.Get(typeof(Parent), r.Name); Assert.IsTrue(NHibernateUtil.IsInitialized(r.Children)); // The test for True is the test of H3.2 @@ -321,7 +321,7 @@ public void SubselectFetchCriteria() s = OpenSession(); t = s.BeginTransaction(); - sessions.Statistics.Clear(); + Sfi.Statistics.Clear(); IList parents = s.CreateCriteria(typeof(Parent)) .Add(Expression.Between("Name", "bar", "foo")) @@ -354,7 +354,7 @@ public void SubselectFetchCriteria() Assert.IsTrue(NHibernateUtil.IsInitialized(q.MoreChildren[0])); - Assert.AreEqual(3, sessions.Statistics.PrepareStatementCount); + Assert.AreEqual(3, Sfi.Statistics.PrepareStatementCount); Child c = (Child) p.Children[0]; NHibernateUtil.Initialize(c.Friends); diff --git a/src/NHibernate.Test/SystemTransactions/TransactionFixture.cs b/src/NHibernate.Test/SystemTransactions/TransactionFixture.cs index c357040fbff..cad02f86e90 100644 --- a/src/NHibernate.Test/SystemTransactions/TransactionFixture.cs +++ b/src/NHibernate.Test/SystemTransactions/TransactionFixture.cs @@ -17,7 +17,7 @@ protected override IList Mappings public void CanUseSystemTransactionsToCommit() { object identifier; - using(ISession session = sessions.OpenSession()) + using(ISession session = Sfi.OpenSession()) using(TransactionScope tx = new TransactionScope()) { W s = new W(); @@ -26,7 +26,7 @@ public void CanUseSystemTransactionsToCommit() tx.Complete(); } - using (ISession session = sessions.OpenSession()) + using (ISession session = Sfi.OpenSession()) using (TransactionScope tx = new TransactionScope()) { W w = session.Get(identifier); diff --git a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs index db9c0b0fa4a..340c6f8dfb6 100644 --- a/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs +++ b/src/NHibernate.Test/SystemTransactions/TransactionNotificationFixture.cs @@ -20,7 +20,7 @@ protected override IList Mappings public void NoTransaction() { var interceptor = new RecordingInterceptor(); - using (sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { Assert.AreEqual(0, interceptor.afterTransactionBeginCalled); Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); @@ -33,7 +33,7 @@ public void AfterBegin() { var interceptor = new RecordingInterceptor(); using (new TransactionScope()) - using (sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { Assert.AreEqual(1, interceptor.afterTransactionBeginCalled); Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); @@ -48,7 +48,7 @@ public void Complete() ISession session; using(var scope = new TransactionScope()) { - session = sessions.WithOptions().Interceptor(interceptor).OpenSession(); + session = Sfi.WithOptions().Interceptor(interceptor).OpenSession(); scope.Complete(); } session.Dispose(); @@ -62,7 +62,7 @@ public void Rollback() { var interceptor = new RecordingInterceptor(); using (new TransactionScope()) - using (sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { } Assert.AreEqual(0, interceptor.beforeTransactionCompletionCalled); @@ -73,7 +73,7 @@ public void Rollback() public void TwoTransactionScopesInsideOneSession() { var interceptor = new RecordingInterceptor(); - using (var session = sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (var session = Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { using (var scope = new TransactionScope()) { @@ -96,7 +96,7 @@ public void TwoTransactionScopesInsideOneSession() public void OneTransactionScopesInsideOneSession() { var interceptor = new RecordingInterceptor(); - using (var session = sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (var session = Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { using (var scope = new TransactionScope()) { @@ -161,11 +161,11 @@ public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doComm using (var tx = new TransactionScope()) { - var ownConnection1 = sessions.ConnectionProvider.GetConnection(); + var ownConnection1 = Sfi.ConnectionProvider.GetConnection(); try { - using (s1 = sessions.WithOptions().Connection(ownConnection1).Interceptor(interceptor).OpenSession()) + using (s1 = Sfi.WithOptions().Connection(ownConnection1).Interceptor(interceptor).OpenSession()) { s1.CreateCriteria().List(); } @@ -175,7 +175,7 @@ public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doComm } finally { - sessions.ConnectionProvider.CloseConnection(ownConnection1); + Sfi.ConnectionProvider.CloseConnection(ownConnection1); } } diff --git a/src/NHibernate.Test/TestCase.cs b/src/NHibernate.Test/TestCase.cs index 5da9a08cfd7..5824997b10b 100644 --- a/src/NHibernate.Test/TestCase.cs +++ b/src/NHibernate.Test/TestCase.cs @@ -12,12 +12,8 @@ using NHibernate.Type; using NUnit.Framework; using NHibernate.Hql.Ast.ANTLR; -using System.Collections.Concurrent; -using System.IO; using NUnit.Framework.Interfaces; using System.Text; -using log4net.Util; -using static NUnit.Framework.TestContext; namespace NHibernate.Test { @@ -25,7 +21,7 @@ public abstract class TestCase { private const bool OutputDdl = false; protected Configuration cfg; - protected ISessionFactoryImplementor sessions; + private DebugSessionFactory _sessionFactory; private static readonly ILog log = LogManager.GetLogger(typeof(TestCase)); @@ -39,21 +35,6 @@ protected TestDialect TestDialect get { return TestDialect.GetTestDialect(Dialect); } } - /// - /// To use in in-line test - /// - protected bool IsAntlrParser - { - get - { - return sessions.Settings.QueryTranslatorFactory is ASTQueryTranslatorFactory; - } - } - - private ConcurrentBag _openedSessions = new ConcurrentBag(); - private ISession _lastOpenedSession; - private DebugConnectionProvider connectionProvider; - /// /// Mapping files used in the TestCase /// @@ -90,8 +71,8 @@ public void TestFixtureSetUp() CreateSchema(); try { - BuildSessionFactory(); - if (!AppliesTo(sessions)) + _sessionFactory = BuildSessionFactory(); + if (!AppliesTo(_sessionFactory)) { Assert.Ignore(GetType() + " does not apply with the current session-factory configuration"); } @@ -110,6 +91,11 @@ public void TestFixtureSetUp() } } + protected void RebuildSessionFactory() + { + _sessionFactory = BuildSessionFactory(); + } + /// /// Removes the tables used in this TestCase. /// @@ -166,7 +152,7 @@ public void TearDown() try { OnTearDown(); - var wereClosed = CheckSessionsWereClosed(); + var wereClosed = _sessionFactory.CheckSessionsWereClosed(); var wasCleaned = CheckDatabaseWasCleaned(); var wereConnectionsClosed = CheckConnectionsWereClosed(); fail = !wereClosed || !wasCleaned || !wereConnectionsClosed; @@ -200,7 +186,7 @@ public void TearDown() } } - private string GetCombinedFailureMessage(ResultAdapter result, string tearDownFailure, string tearDownStackTrace) + private string GetCombinedFailureMessage(TestContext.ResultAdapter result, string tearDownFailure, string tearDownStackTrace) { var message = new StringBuilder() .Append("The test failed and then failed to cleanup. Test failure is: ") @@ -217,26 +203,9 @@ private string GetCombinedFailureMessage(ResultAdapter result, string tearDownFa return message.ToString(); } - // Factory is exposed to descendant, any session opened directly from it will not be handled by following check. - private bool CheckSessionsWereClosed() - { - var allClosed = true; - foreach (var session in _openedSessions) - { - if (session.IsOpen) - { - log.Error($"Test case didn't close session {session.GetSessionImplementation().SessionId}, closing"); - allClosed = false; - session.Close(); - } - } - - return allClosed; - } - protected virtual bool CheckDatabaseWasCleaned() { - if (sessions.GetAllClassMetadata().Count == 0) + if (Sfi.GetAllClassMetadata().Count == 0) { // Return early in the case of no mappings, also avoiding // a warning when executing the HQL below. @@ -244,7 +213,7 @@ protected virtual bool CheckDatabaseWasCleaned() } bool empty; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { IList objects = s.CreateQuery("from System.Object o").List(); empty = objects.Count == 0; @@ -262,13 +231,13 @@ protected virtual bool CheckDatabaseWasCleaned() private bool CheckConnectionsWereClosed() { - if (connectionProvider == null || !connectionProvider.HasOpenConnections) + if (_sessionFactory?.ConnectionProvider?.HasOpenConnections != true) { return true; } log.Error("Test case didn't close all open connections, closing"); - connectionProvider.CloseAllConnections(); + _sessionFactory.ConnectionProvider.CloseAllConnections(); return false; } @@ -303,22 +272,15 @@ protected virtual void DropSchema() new SchemaExport(cfg).Drop(OutputDdl, true); } - protected virtual void BuildSessionFactory() + protected virtual DebugSessionFactory BuildSessionFactory() { - sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory(); - connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider; + return new DebugSessionFactory(cfg.BuildSessionFactory()); } private void Cleanup() { - if (sessions != null) - { - sessions.Close(); - } - sessions = null; - connectionProvider = null; - _lastOpenedSession = null; - _openedSessions = new ConcurrentBag(); + Sfi?.Close(); + _sessionFactory = null; cfg = null; } @@ -364,23 +326,16 @@ public int ExecuteStatement(ISession session, ITransaction transaction, string s } } - protected ISessionFactoryImplementor Sfi - { - get { return sessions; } - } + protected ISessionFactoryImplementor Sfi => _sessionFactory; protected virtual ISession OpenSession() { - _lastOpenedSession = sessions.OpenSession(); - _openedSessions.Add(_lastOpenedSession); - return _lastOpenedSession; + return Sfi.OpenSession(); } protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor) { - _lastOpenedSession = sessions.WithOptions().Interceptor(sessionLocalInterceptor).OpenSession(); - _openedSessions.Add(_lastOpenedSession); - return _lastOpenedSession; + return Sfi.WithOptions().Interceptor(sessionLocalInterceptor).OpenSession(); } protected virtual void ApplyCacheSettings(Configuration configuration) @@ -398,7 +353,7 @@ protected virtual void ApplyCacheSettings(Configuration configuration) if (prop.Value.IsSimpleValue) { IType type = ((SimpleValue)prop.Value).Type; - if (type == NHibernateUtil.BinaryBlob) + if (ReferenceEquals(type, NHibernateUtil.BinaryBlob)) { hasLob = true; } diff --git a/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs b/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs index 0fd9a5d3624..7d7a64fb960 100644 --- a/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs +++ b/src/NHibernate.Test/TransactionTest/TransactionNotificationFixture.cs @@ -17,7 +17,7 @@ protected override IList Mappings public void NoTransaction() { var interceptor = new RecordingInterceptor(); - using (sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { Assert.That(interceptor.afterTransactionBeginCalled, Is.EqualTo(0)); Assert.That(interceptor.beforeTransactionCompletionCalled, Is.EqualTo(0)); @@ -29,7 +29,7 @@ public void NoTransaction() public void AfterBegin() { var interceptor = new RecordingInterceptor(); - using (var session = sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (var session = Sfi.WithOptions().Interceptor(interceptor).OpenSession()) using (session.BeginTransaction()) { Assert.That(interceptor.afterTransactionBeginCalled, Is.EqualTo(1)); @@ -42,7 +42,7 @@ public void AfterBegin() public void Commit() { var interceptor = new RecordingInterceptor(); - using (var session = sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (var session = Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { ITransaction tx = session.BeginTransaction(); tx.Commit(); @@ -56,7 +56,7 @@ public void Commit() public void Rollback() { var interceptor = new RecordingInterceptor(); - using (var session = sessions.WithOptions().Interceptor(interceptor).OpenSession()) + using (var session = Sfi.WithOptions().Interceptor(interceptor).OpenSession()) { ITransaction tx = session.BeginTransaction(); tx.Rollback(); @@ -96,9 +96,9 @@ public void ShouldNotifyAfterTransactionWithOwnConnection(bool usePrematureClose var interceptor = new RecordingInterceptor(); ISession s; - using (var ownConnection = sessions.ConnectionProvider.GetConnection()) + using (var ownConnection = Sfi.ConnectionProvider.GetConnection()) { - using (s = sessions.WithOptions().Connection(ownConnection).Interceptor(interceptor).OpenSession()) + using (s = Sfi.WithOptions().Connection(ownConnection).Interceptor(interceptor).OpenSession()) using (s.BeginTransaction()) { s.CreateCriteria().List(); diff --git a/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs b/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs index a64abc914e1..1350651ba20 100644 --- a/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs +++ b/src/NHibernate.Test/TypeParameters/TypeParameterTest.cs @@ -54,7 +54,7 @@ public void Save() s = OpenSession(); t = s.BeginTransaction(); - IDriver driver = sessions.ConnectionProvider.Driver; + IDriver driver = Sfi.ConnectionProvider.Driver; var connection = s.Connection; var statement = driver.GenerateCommand( diff --git a/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs b/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs index c548a3b1fc0..f025b3466cb 100644 --- a/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs +++ b/src/NHibernate.Test/TypedManyToOne/TypedManyToOneTest.cs @@ -42,14 +42,14 @@ public void TestCreateQuery() cust.BillingAddress = bill; cust.ShippingAddress = ship; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Persist(cust); t.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress where cust.CustomerId='abc123'").List(); @@ -64,7 +64,7 @@ public void TestCreateQuery() t.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.SaveOrUpdate(cust); @@ -87,14 +87,14 @@ public void TestCreateQueryNull() cust.CustomerId = "xyz123"; cust.Name = "Matt"; - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { s.Persist(cust); t.Commit(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) using (ITransaction t = s.BeginTransaction()) { IList results = s.CreateQuery("from Customer cust left join fetch cust.BillingAddress where cust.CustomerId='xyz123'").List(); diff --git a/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs b/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs index 1705f82e8c2..ce16fefbb85 100644 --- a/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs @@ -45,9 +45,9 @@ public void Equals() EntityClass b = new EntityClass(2); EntityClass c = new EntityClass(1); - Assert.IsTrue(type.IsEqual(a, a, (ISessionFactoryImplementor) sessions)); - Assert.IsFalse(type.IsEqual(a, b, (ISessionFactoryImplementor) sessions)); - Assert.IsTrue(type.IsEqual(a, c, (ISessionFactoryImplementor) sessions)); + Assert.IsTrue(type.IsEqual(a, a, (ISessionFactoryImplementor) Sfi)); + Assert.IsFalse(type.IsEqual(a, b, (ISessionFactoryImplementor) Sfi)); + Assert.IsTrue(type.IsEqual(a, c, (ISessionFactoryImplementor) Sfi)); } } } diff --git a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs index b068f6dfebd..50a1818d262 100644 --- a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs @@ -84,7 +84,7 @@ public void UsageInHqlSelectNew() s.Flush(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { s.CreateQuery("select new PersistentEnumHolder(p.A, p.B) from PersistentEnumClass p").List(); s.Delete("from PersistentEnumClass"); @@ -101,7 +101,7 @@ public void UsageInHqlSelectNewInvalidConstructor() s.Flush(); } - ISession s2 = sessions.OpenSession(); + ISession s2 = Sfi.OpenSession(); try { Assert.Throws( @@ -125,7 +125,7 @@ public void CanWriteAndReadUsingBothHeuristicAndExplicitGenericDeclaration() s.Flush(); } - using (ISession s = sessions.OpenSession()) + using (ISession s = Sfi.OpenSession()) { var saved = s.Get(1); Assert.That(saved.A, Is.EqualTo(A.Two)); diff --git a/src/NHibernate.Test/TypesTest/StringTypeWithLengthFixture.cs b/src/NHibernate.Test/TypesTest/StringTypeWithLengthFixture.cs index 21cfd8b68d8..3717c0f746f 100644 --- a/src/NHibernate.Test/TypesTest/StringTypeWithLengthFixture.cs +++ b/src/NHibernate.Test/TypesTest/StringTypeWithLengthFixture.cs @@ -171,7 +171,7 @@ public void CriteriaLikeParameterCanExceedColumnSize() // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column. AssertExpectedFailureOrNoException( exception, - (sessions.ConnectionProvider.Driver is OdbcDriver)); + (Sfi.ConnectionProvider.Driver is OdbcDriver)); } [Test] @@ -199,7 +199,7 @@ public void HqlLikeParameterCanExceedColumnSize() // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column. AssertExpectedFailureOrNoException( exception, - (sessions.ConnectionProvider.Driver is OdbcDriver)); + (Sfi.ConnectionProvider.Driver is OdbcDriver)); } @@ -231,7 +231,7 @@ public void CriteriaEqualityParameterCanExceedColumnSize() // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column. AssertExpectedFailureOrNoException( exception, - (Dialect is FirebirdDialect) || (sessions.ConnectionProvider.Driver is OdbcDriver)); + (Dialect is FirebirdDialect) || (Sfi.ConnectionProvider.Driver is OdbcDriver)); } @@ -263,7 +263,7 @@ public void HqlEqualityParameterCanExceedColumnSize() // This test fails against the ODBC driver. The driver would need to be override to allow longer parameter sizes than the column. AssertExpectedFailureOrNoException( exception, - (Dialect is FirebirdDialect) || (sessions.ConnectionProvider.Driver is OdbcDriver)); + (Dialect is FirebirdDialect) || (Sfi.ConnectionProvider.Driver is OdbcDriver)); } diff --git a/src/NHibernate.Test/TypesTest/UriTypeFixture.cs b/src/NHibernate.Test/TypesTest/UriTypeFixture.cs index 628601bb2ce..b05cb0659d3 100644 --- a/src/NHibernate.Test/TypesTest/UriTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/UriTypeFixture.cs @@ -94,7 +94,7 @@ public void InsertNullValue() public void AutoDiscoverFromNetType() { // integration test to be 100% sure - var propertyType = sessions.GetEntityPersister(typeof(UriClass).FullName).GetPropertyType("AutoUri"); + var propertyType = Sfi.GetEntityPersister(typeof(UriClass).FullName).GetPropertyType("AutoUri"); Assert.That(propertyType, Is.InstanceOf()); } diff --git a/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs b/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs index 36bd03fd483..c57ab77a9be 100644 --- a/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/XDocTypeFixture.cs @@ -75,7 +75,7 @@ public void InsertNullValue() public void AutoDiscoverFromNetType() { // integration test to be 100% sure - var propertyType = sessions.GetEntityPersister(typeof (XDocClass).FullName).GetPropertyType("AutoDocument"); + var propertyType = Sfi.GetEntityPersister(typeof (XDocClass).FullName).GetPropertyType("AutoDocument"); Assert.That(propertyType, Is.InstanceOf()); } } diff --git a/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs b/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs index aadce4b7bc2..df94b43c40f 100644 --- a/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/XmlDocTypeFixture.cs @@ -75,7 +75,7 @@ public void InsertNullValue() public void AutoDiscoverFromNetType() { // integration test to be 100% sure - var propertyType = sessions.GetEntityPersister(typeof (XmlDocClass).FullName).GetPropertyType("AutoDocument"); + var propertyType = Sfi.GetEntityPersister(typeof (XmlDocClass).FullName).GetPropertyType("AutoDocument"); Assert.That(propertyType, Is.InstanceOf()); } } diff --git a/src/NHibernate.Test/Unconstrained/UnconstrainedNoLazyTest.cs b/src/NHibernate.Test/Unconstrained/UnconstrainedNoLazyTest.cs index b4a5ffa3575..d407619197b 100644 --- a/src/NHibernate.Test/Unconstrained/UnconstrainedNoLazyTest.cs +++ b/src/NHibernate.Test/Unconstrained/UnconstrainedNoLazyTest.cs @@ -31,7 +31,7 @@ public void UnconstrainedNoCache() tx.Commit(); session.Close(); - sessions.Evict(typeof(Person)); + Sfi.Evict(typeof(Person)); session = OpenSession(); tx = session.BeginTransaction(); @@ -41,7 +41,7 @@ public void UnconstrainedNoCache() tx.Commit(); session.Close(); - sessions.Evict(typeof(Person)); + Sfi.Evict(typeof(Person)); session = OpenSession(); tx = session.BeginTransaction(); @@ -64,7 +64,7 @@ public void UnconstrainedOuterJoinFetch() tx.Commit(); session.Close(); - sessions.Evict(typeof(Person)); + Sfi.Evict(typeof(Person)); session = OpenSession(); tx = session.BeginTransaction(); @@ -77,7 +77,7 @@ public void UnconstrainedOuterJoinFetch() tx.Commit(); session.Close(); - sessions.Evict(typeof(Person)); + Sfi.Evict(typeof(Person)); session = OpenSession(); tx = session.BeginTransaction(); diff --git a/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs b/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs index 18c5554b974..82bfab6e543 100644 --- a/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs +++ b/src/NHibernate.Test/VersionTest/Db/MsSQL/GeneratedBinaryVersionFixture.cs @@ -100,7 +100,7 @@ public void ShouldCheckStaleState() versioned.Something = "new string"; - var expectedException = sessions.Settings.IsBatchVersionedDataEnabled + var expectedException = Sfi.Settings.IsBatchVersionedDataEnabled ? Throws.InstanceOf() : Throws.InstanceOf();