CloneSet16


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
228430.987class_member_declarations[19]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
122485
src/NHibernate.ByteCode.Castle.Tests/TestCase.cs
222485
src/NHibernate.ByteCode.LinFu.Tests/TestCase.cs
322485
src/NHibernate.ByteCode.Spring.Tests/TestCase.cs
4228115
src/NHibernate.Test/TestCase.cs
Clone Instance
1
Line Count
224
Source Line
85
Source File
src/NHibernate.ByteCode.Castle.Tests/TestCase.cs

                /// <summary>
                /// Removes the tables used in this TestCase.
                /// </summary>
                /// <remarks>
                /// If the tables are not cleaned up sometimes SchemaExport runs into
                /// Sql errors because it can't drop tables because of the FKs.  This 
                /// will occur if the TestCase does not have the same hbm.xml files
                /// included as a previous one.
                /// </remarks>
                [TestFixtureTearDown]
                public void TestFixtureTearDown()
                {
                        DropSchema();
                        Cleanup();
                }

                protected virtual void OnSetUp()
                {
                }

                /// <summary>
                /// Set up the test. This method is not overridable, but it calls
                /// <see cref="OnSetUp" /> which is.
                /// </summary>
                [SetUp]
                public void SetUp()
                {
                        OnSetUp();
                }

                protected virtual void OnTearDown()
                {
                }

                /// <summary>
                /// Checks that the test case cleans up after itself. This method
                /// is not overridable, but it calls <see cref="OnTearDown" /> which is.
                /// </summary>
                [TearDown]
                public void TearDown()
                {
                        OnTearDown();

                        bool wasClosed = CheckSessionWasClosed();
                        bool wasCleaned = CheckDatabaseWasCleaned();
                        bool wereConnectionsClosed = CheckConnectionsWereClosed();
                        bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;

                        if (fail)
                        {
                                Assert.Fail("Test didn't clean up after itself");
                        }
                }

                private bool CheckSessionWasClosed()
                {
                        if (lastOpenedSession != null && lastOpenedSession.IsOpen)
                        {
                                log.Error("Test case didn't close a session, closing");
                                lastOpenedSession.Close();
                                return false;
                        }

                        return true;
                }

                private bool CheckDatabaseWasCleaned()
                {
                        if (sessions.GetAllClassMetadata().Count == 0)
                        {
                                // Return early in the case of no mappings, also avoiding
                                // a warning when executing the HQL below.
                                return true;
                        }

                        bool empty;
                        using (ISession s = sessions.OpenSession())
                        {
                                IList objects = s.CreateQuery("from System.Object o").List();
                                empty = objects.Count == 0;
                        }

                        if ( !empty)
                        {
                                log.Error("Test case didn't clean up the database after itself, re-creating the schema");
                                DropSchema();
                                CreateSchema();
                        }

                        return empty;
                }

                private bool CheckConnectionsWereClosed()
                {
                        if (connectionProvider == null || !connectionProvider.HasOpenConnections)
                        {
                                return true;
                        }

                        log.Error("Test case didn't close all open connections, closing");
                        connectionProvider.CloseAllConnections();
                        return false;
                }

                private void Configure()
                {
                        cfg = new Configuration();
                        if (TestConfigurationHelper.hibernateConfigFile != null)
                                cfg.Configure(TestConfigurationHelper.hibernateConfigFile);

                        Assembly assembly = Assembly.Load(MappingsAssembly);

                        foreach (string file in Mappings)
                        {
                                cfg.AddResource(MappingsAssembly + "." + file, assembly);
                        }

                        Configure(cfg);

                        ApplyCacheSettings(cfg);
                }

                private void CreateSchema()
                {
                        new SchemaExport(cfg).Create(OutputDdl, true);
                }

                private void DropSchema()
                {
                        new SchemaExport(cfg).Drop(OutputDdl, true);
                }

                protected virtual void BuildSessionFactory()
                {
                        sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
                        connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
                }

                private void Cleanup()
                {
                        sessions.Close();
                        sessions = null;
                        connectionProvider = null;
                        lastOpenedSession = null;
                        cfg = null;
                }

                public int ExecuteStatement(string sql)
                {
                        if (cfg == null)
                        {
                                cfg = new Configuration();
                        }

                        using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
                        {
                                IDbConnection conn = prov.GetConnection();

                                try
                                {
                                        using (IDbTransaction tran = conn.BeginTransaction())
                                        using (IDbCommand comm = conn.CreateCommand())
                                        {
                                                comm.CommandText = sql;
                                                comm.Transaction = tran;
                                                comm.CommandType = CommandType.Text;
                                                int result = comm.ExecuteNonQuery();
                                                tran.Commit();
                                                return result;
                                        }
                                }
                                finally
                                {
                                        prov.CloseConnection(conn);
                                }
                        }
                }

                protected ISessionFactoryImplementor Sfi
                {
                        get { return sessions;
                            }
                }

                protected virtual ISession OpenSession()
                {
                        lastOpenedSession = sessions.OpenSession();
                        return lastOpenedSession;
                }

                protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
                {
                        lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
                        return lastOpenedSession;
                }

                protected void ApplyCacheSettings(Configuration configuration)
                {
                        if (CacheConcurrencyStrategy == null)
                        {
                                return;
                        }

                        foreach (PersistentClass clazz in configuration.ClassMappings)
                        {
                                bool hasLob = false;
                                foreach (Property prop in clazz.PropertyClosureIterator)
                                {
                                        if (prop.Value.IsSimpleValue)
                                        {
                                                IType type = ((SimpleValue)prop.Value).Type;
                                                if (type == NHibernateUtil.BinaryBlob)
                                                {
                                                        hasLob = true;
                                                }
                                        }
                                }
                                if ( !hasLob && !clazz.IsInherited)
                                {
                                        configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
                                }
                        }

                        foreach (Mapping.Collection coll in configuration.CollectionMappings)
                        {
                                configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
                        }
                }

                #region Properties overridable by subclasses
                protected virtual bool AppliesTo(Dialect.Dialect dialect)
                {
                        return true;
                }



Clone Instance
2
Line Count
224
Source Line
85
Source File
src/NHibernate.ByteCode.LinFu.Tests/TestCase.cs

                /// <summary>
                /// Removes the tables used in this TestCase.
                /// </summary>
                /// <remarks>
                /// If the tables are not cleaned up sometimes SchemaExport runs into
                /// Sql errors because it can't drop tables because of the FKs.  This 
                /// will occur if the TestCase does not have the same hbm.xml files
                /// included as a previous one.
                /// </remarks>
                [TestFixtureTearDown]
                public void TestFixtureTearDown()
                {
                        DropSchema();
                        Cleanup();
                }

                protected virtual void OnSetUp()
                {
                }

                /// <summary>
                /// Set up the test. This method is not overridable, but it calls
                /// <see cref="OnSetUp" /> which is.
                /// </summary>
                [SetUp]
                public void SetUp()
                {
                        OnSetUp();
                }

                protected virtual void OnTearDown()
                {
                }

                /// <summary>
                /// Checks that the test case cleans up after itself. This method
                /// is not overridable, but it calls <see cref="OnTearDown" /> which is.
                /// </summary>
                [TearDown]
                public void TearDown()
                {
                        OnTearDown();

                        bool wasClosed = CheckSessionWasClosed();
                        bool wasCleaned = CheckDatabaseWasCleaned();
                        bool wereConnectionsClosed = CheckConnectionsWereClosed();
                        bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;

                        if (fail)
                        {
                                Assert.Fail("Test didn't clean up after itself");
                        }
                }

                private bool CheckSessionWasClosed()
                {
                        if (lastOpenedSession != null && lastOpenedSession.IsOpen)
                        {
                                log.Error("Test case didn't close a session, closing");
                                lastOpenedSession.Close();
                                return false;
                        }

                        return true;
                }

                private bool CheckDatabaseWasCleaned()
                {
                        if (sessions.GetAllClassMetadata().Count == 0)
                        {
                                // Return early in the case of no mappings, also avoiding
                                // a warning when executing the HQL below.
                                return true;
                        }

                        bool empty;
                        using (ISession s = sessions.OpenSession())
                        {
                                IList objects = s.CreateQuery("from System.Object o").List();
                                empty = objects.Count == 0;
                        }

                        if ( !empty)
                        {
                                log.Error("Test case didn't clean up the database after itself, re-creating the schema");
                                DropSchema();
                                CreateSchema();
                        }

                        return empty;
                }

                private bool CheckConnectionsWereClosed()
                {
                        if (connectionProvider == null || !connectionProvider.HasOpenConnections)
                        {
                                return true;
                        }

                        log.Error("Test case didn't close all open connections, closing");
                        connectionProvider.CloseAllConnections();
                        return false;
                }

                private void Configure()
                {
                        cfg = new Configuration();
                        if (TestConfigurationHelper.hibernateConfigFile != null)
                                cfg.Configure(TestConfigurationHelper.hibernateConfigFile);

                        Assembly assembly = Assembly.Load(MappingsAssembly);

                        foreach (string file in Mappings)
                        {
                                cfg.AddResource(MappingsAssembly + "." + file, assembly);
                        }

                        Configure(cfg);

                        ApplyCacheSettings(cfg);
                }

                private void CreateSchema()
                {
                        new SchemaExport(cfg).Create(OutputDdl, true);
                }

                private void DropSchema()
                {
                        new SchemaExport(cfg).Drop(OutputDdl, true);
                }

                protected virtual void BuildSessionFactory()
                {
                        sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
                        connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
                }

                private void Cleanup()
                {
                        sessions.Close();
                        sessions = null;
                        connectionProvider = null;
                        lastOpenedSession = null;
                        cfg = null;
                }

                public int ExecuteStatement(string sql)
                {
                        if (cfg == null)
                        {
                                cfg = new Configuration();
                        }

                        using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
                        {
                                IDbConnection conn = prov.GetConnection();

                                try
                                {
                                        using (IDbTransaction tran = conn.BeginTransaction())
                                        using (IDbCommand comm = conn.CreateCommand())
                                        {
                                                comm.CommandText = sql;
                                                comm.Transaction = tran;
                                                comm.CommandType = CommandType.Text;
                                                int result = comm.ExecuteNonQuery();
                                                tran.Commit();
                                                return result;
                                        }
                                }
                                finally
                                {
                                        prov.CloseConnection(conn);
                                }
                        }
                }

                protected ISessionFactoryImplementor Sfi
                {
                        get { return sessions;
                            }
                }

                protected virtual ISession OpenSession()
                {
                        lastOpenedSession = sessions.OpenSession();
                        return lastOpenedSession;
                }

                protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
                {
                        lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
                        return lastOpenedSession;
                }

                protected void ApplyCacheSettings(Configuration configuration)
                {
                        if (CacheConcurrencyStrategy == null)
                        {
                                return;
                        }

                        foreach (PersistentClass clazz in configuration.ClassMappings)
                        {
                                bool hasLob = false;
                                foreach (Property prop in clazz.PropertyClosureIterator)
                                {
                                        if (prop.Value.IsSimpleValue)
                                        {
                                                IType type = ((SimpleValue)prop.Value).Type;
                                                if (type == NHibernateUtil.BinaryBlob)
                                                {
                                                        hasLob = true;
                                                }
                                        }
                                }
                                if ( !hasLob && !clazz.IsInherited)
                                {
                                        configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
                                }
                        }

                        foreach (Mapping.Collection coll in configuration.CollectionMappings)
                        {
                                configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
                        }
                }

                #region Properties overridable by subclasses
                protected virtual bool AppliesTo(Dialect.Dialect dialect)
                {
                        return true;
                }



Clone Instance
3
Line Count
224
Source Line
85
Source File
src/NHibernate.ByteCode.Spring.Tests/TestCase.cs

                /// <summary>
                /// Removes the tables used in this TestCase.
                /// </summary>
                /// <remarks>
                /// If the tables are not cleaned up sometimes SchemaExport runs into
                /// Sql errors because it can't drop tables because of the FKs.  This 
                /// will occur if the TestCase does not have the same hbm.xml files
                /// included as a previous one.
                /// </remarks>
                [TestFixtureTearDown]
                public void TestFixtureTearDown()
                {
                        DropSchema();
                        Cleanup();
                }

                protected virtual void OnSetUp()
                {
                }

                /// <summary>
                /// Set up the test. This method is not overridable, but it calls
                /// <see cref="OnSetUp" /> which is.
                /// </summary>
                [SetUp]
                public void SetUp()
                {
                        OnSetUp();
                }

                protected virtual void OnTearDown()
                {
                }

                /// <summary>
                /// Checks that the test case cleans up after itself. This method
                /// is not overridable, but it calls <see cref="OnTearDown" /> which is.
                /// </summary>
                [TearDown]
                public void TearDown()
                {
                        OnTearDown();

                        bool wasClosed = CheckSessionWasClosed();
                        bool wasCleaned = CheckDatabaseWasCleaned();
                        bool wereConnectionsClosed = CheckConnectionsWereClosed();
                        bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;

                        if (fail)
                        {
                                Assert.Fail("Test didn't clean up after itself");
                        }
                }

                private bool CheckSessionWasClosed()
                {
                        if (lastOpenedSession != null && lastOpenedSession.IsOpen)
                        {
                                log.Error("Test case didn't close a session, closing");
                                lastOpenedSession.Close();
                                return false;
                        }

                        return true;
                }

                private bool CheckDatabaseWasCleaned()
                {
                        if (sessions.GetAllClassMetadata().Count == 0)
                        {
                                // Return early in the case of no mappings, also avoiding
                                // a warning when executing the HQL below.
                                return true;
                        }

                        bool empty;
                        using (ISession s = sessions.OpenSession())
                        {
                                IList objects = s.CreateQuery("from System.Object o").List();
                                empty = objects.Count == 0;
                        }

                        if ( !empty)
                        {
                                log.Error("Test case didn't clean up the database after itself, re-creating the schema");
                                DropSchema();
                                CreateSchema();
                        }

                        return empty;
                }

                private bool CheckConnectionsWereClosed()
                {
                        if (connectionProvider == null || !connectionProvider.HasOpenConnections)
                        {
                                return true;
                        }

                        log.Error("Test case didn't close all open connections, closing");
                        connectionProvider.CloseAllConnections();
                        return false;
                }

                private void Configure()
                {
                        cfg = new Configuration();
                        if (TestConfigurationHelper.hibernateConfigFile != null)
                                cfg.Configure(TestConfigurationHelper.hibernateConfigFile);

                        Assembly assembly = Assembly.Load(MappingsAssembly);

                        foreach (string file in Mappings)
                        {
                                cfg.AddResource(MappingsAssembly + "." + file, assembly);
                        }

                        Configure(cfg);

                        ApplyCacheSettings(cfg);
                }

                private void CreateSchema()
                {
                        new SchemaExport(cfg).Create(OutputDdl, true);
                }

                private void DropSchema()
                {
                        new SchemaExport(cfg).Drop(OutputDdl, true);
                }

                protected virtual void BuildSessionFactory()
                {
                        sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
                        connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
                }

                private void Cleanup()
                {
                        sessions.Close();
                        sessions = null;
                        connectionProvider = null;
                        lastOpenedSession = null;
                        cfg = null;
                }

                public int ExecuteStatement(string sql)
                {
                        if (cfg == null)
                        {
                                cfg = new Configuration();
                        }

                        using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
                        {
                                IDbConnection conn = prov.GetConnection();

                                try
                                {
                                        using (IDbTransaction tran = conn.BeginTransaction())
                                        using (IDbCommand comm = conn.CreateCommand())
                                        {
                                                comm.CommandText = sql;
                                                comm.Transaction = tran;
                                                comm.CommandType = CommandType.Text;
                                                int result = comm.ExecuteNonQuery();
                                                tran.Commit();
                                                return result;
                                        }
                                }
                                finally
                                {
                                        prov.CloseConnection(conn);
                                }
                        }
                }

                protected ISessionFactoryImplementor Sfi
                {
                        get { return sessions;
                            }
                }

                protected virtual ISession OpenSession()
                {
                        lastOpenedSession = sessions.OpenSession();
                        return lastOpenedSession;
                }

                protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
                {
                        lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
                        return lastOpenedSession;
                }

                protected void ApplyCacheSettings(Configuration configuration)
                {
                        if (CacheConcurrencyStrategy == null)
                        {
                                return;
                        }

                        foreach (PersistentClass clazz in configuration.ClassMappings)
                        {
                                bool hasLob = false;
                                foreach (Property prop in clazz.PropertyClosureIterator)
                                {
                                        if (prop.Value.IsSimpleValue)
                                        {
                                                IType type = ((SimpleValue)prop.Value).Type;
                                                if (type == NHibernateUtil.BinaryBlob)
                                                {
                                                        hasLob = true;
                                                }
                                        }
                                }
                                if ( !hasLob && !clazz.IsInherited)
                                {
                                        configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
                                }
                        }

                        foreach (Mapping.Collection coll in configuration.CollectionMappings)
                        {
                                configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
                        }
                }

                #region Properties overridable by subclasses
                protected virtual bool AppliesTo(Dialect.Dialect dialect)
                {
                        return true;
                }



Clone Instance
4
Line Count
228
Source Line
115
Source File
src/NHibernate.Test/TestCase.cs

                /// <summary>
                /// Removes the tables used in this TestCase.
                /// </summary>
                /// <remarks>
                /// If the tables are not cleaned up sometimes SchemaExport runs into
                /// Sql errors because it can't drop tables because of the FKs.  This 
                /// will occur if the TestCase does not have the same hbm.xml files
                /// included as a previous one.
                /// </remarks>
                [TestFixtureTearDown]
                public void TestFixtureTearDown()
                {
                        DropSchema();
                        Cleanup();
                }

                protected virtual void OnSetUp()
                {
                }

                /// <summary>
                /// Set up the test. This method is not overridable, but it calls
                /// <see cref="OnSetUp" /> which is.
                /// </summary>
                [SetUp]
                public void SetUp()
                {
                        OnSetUp();
                }

                protected virtual void OnTearDown()
                {
                }

                /// <summary>
                /// Checks that the test case cleans up after itself. This method
                /// is not overridable, but it calls <see cref="OnTearDown" /> which is.
                /// </summary>
                [TearDown]
                public void TearDown()
                {
                        OnTearDown();

                        bool wasClosed = CheckSessionWasClosed();
                        bool wasCleaned = CheckDatabaseWasCleaned();
                        bool wereConnectionsClosed = CheckConnectionsWereClosed();
                        bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;

                        if (fail)
                        {
                Assert.Fail("Test didn't clean up after itself. session closed: " + wasClosed + " database cleaned: " + wasCleaned +
                      " connection closed: " + wereConnectionsClosed);
                        }
                }

                private bool CheckSessionWasClosed()
                {
                        if (lastOpenedSession != null && lastOpenedSession.IsOpen)
                        {
                                log.Error("Test case didn't close a session, closing");
                                lastOpenedSession.Close();
                                return false;
                        }

                        return true;
                }

                private bool CheckDatabaseWasCleaned()
                {
                        if (sessions.GetAllClassMetadata().Count == 0)
                        {
                                // Return early in the case of no mappings, also avoiding
                                // a warning when executing the HQL below.
                                return true;
                        }

                        bool empty;
                        using (ISession s = sessions.OpenSession())
                        {
                                IList objects = s.CreateQuery("from System.Object o").List();
                                empty = objects.Count == 0;
                        }

                        if ( !empty)
                        {
                                log.Error("Test case didn't clean up the database after itself, re-creating the schema");
                                DropSchema();
                                CreateSchema();
                        }

                        return empty;
                }

                private bool CheckConnectionsWereClosed()
                {
                        if (connectionProvider == null || !connectionProvider.HasOpenConnections)
                        {
                                return true;
                        }

                        log.Error("Test case didn't close all open connections, closing");
                        connectionProvider.CloseAllConnections();
                        return false;
                }

                private void Configure()
                {
                        cfg = new Configuration();
                        if (TestConfigurationHelper.hibernateConfigFile != null)
                                cfg.Configure(TestConfigurationHelper.hibernateConfigFile);

                        Assembly assembly = Assembly.Load(MappingsAssembly);

                        foreach (string file in Mappings)
                        {
                                cfg.AddResource(MappingsAssembly + "." + file, assembly);
                        }

                        Configure(cfg);

                        ApplyCacheSettings(cfg);
                }

                protected virtual void CreateSchema()
                {
                        new SchemaExport(cfg).Create(OutputDdl, true);
                }

                private void DropSchema()
                {
                        new SchemaExport(cfg).Drop(OutputDdl, true);
                }

                protected virtual void BuildSessionFactory()
                {
                        sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
                        connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
                }

                private void Cleanup()
                {
                        if (sessions != null)
                        {
                                sessions.Close();
                        }
                        sessions = null;
                        connectionProvider = null;
                        lastOpenedSession = null;
                        cfg = null;
                }

                public int ExecuteStatement(string sql)
                {
                        if (cfg == null)
                        {
                                cfg = new Configuration();
                        }

                        using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
                        {
                                IDbConnection conn = prov.GetConnection();

                                try
                                {
                                        using (IDbTransaction tran = conn.BeginTransaction())
                                        using (IDbCommand comm = conn.CreateCommand())
                                        {
                                                comm.CommandText = sql;
                                                comm.Transaction = tran;
                                                comm.CommandType = CommandType.Text;
                                                int result = comm.ExecuteNonQuery();
                                                tran.Commit();
                                                return result;
                                        }
                                }
                                finally
                                {
                                        prov.CloseConnection(conn);
                                }
                        }
                }

                protected ISessionFactoryImplementor Sfi
                {
                        get { return sessions;
                            }
                }

                protected virtual ISession OpenSession()
                {
                        lastOpenedSession = sessions.OpenSession();
                        return lastOpenedSession;
                }

                protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
                {
                        lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
                        return lastOpenedSession;
                }

                protected void ApplyCacheSettings(Configuration configuration)
                {
                        if (CacheConcurrencyStrategy == null)
                        {
                                return;
                        }

                        foreach (PersistentClass clazz in configuration.ClassMappings)
                        {
                                bool hasLob = false;
                                foreach (Property prop in clazz.PropertyClosureIterator)
                                {
                                        if (prop.Value.IsSimpleValue)
                                        {
                                                IType type = ((SimpleValue)prop.Value).Type;
                                                if (type == NHibernateUtil.BinaryBlob)
                                                {
                                                        hasLob = true;
                                                }
                                        }
                                }
                                if ( !hasLob && !clazz.IsInherited)
                                {
                                        configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
                                }
                        }

                        foreach (Mapping.Collection coll in configuration.CollectionMappings)
                        {
                                configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
                        }
                }

                #region Properties overridable by subclasses
                protected virtual bool AppliesTo(Dialect.Dialect dialect)
                {
                        return true;
                }



Clone AbstractionParameter Count: 3Parameter Bindings

/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs.  This 
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
   DropSchema();
   Cleanup();
}

protected virtual void OnSetUp()
{
}

/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
   OnSetUp();
}

protected virtual void OnTearDown()
{
}

/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
   OnTearDown();
   bool wasClosed = CheckSessionWasClosed();
   bool wasCleaned = CheckDatabaseWasCleaned();
   bool wereConnectionsClosed = CheckConnectionsWereClosed();
   bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
   if (fail)
   {
      Assert.Fail( [[#variable58400de0]]);
   }
}

private bool CheckSessionWasClosed()
{
   if (lastOpenedSession != null && lastOpenedSession.IsOpen)
   {
      log.Error("Test case didn't close a session, closing");
      lastOpenedSession.Close();
      return false;
   }
   return true;
}

private bool CheckDatabaseWasCleaned()
{
   if (sessions.GetAllClassMetadata().Count == 0)
   {
      // Return early in the case of no mappings, also avoiding
      // a warning when executing the HQL below.
      return true;
   }
   bool empty;
   using (ISession s = sessions.OpenSession())
   {
      IList objects = s.CreateQuery("from System.Object o").List();
      empty = objects.Count == 0;
   }
   if ( !empty)
   {
      log.Error("Test case didn't clean up the database after itself, re-creating the schema");
      DropSchema();
      CreateSchema();
   }
   return empty;
}

private bool CheckConnectionsWereClosed()
{
   if (connectionProvider == null || !connectionProvider.HasOpenConnections)
   {
      return true;
   }
   log.Error("Test case didn't close all open connections, closing");
   connectionProvider.CloseAllConnections();
   return false;
}

private void Configure()
{
   cfg = new Configuration();
   if (TestConfigurationHelper.hibernateConfigFile != null)
      cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
   Assembly assembly = Assembly.Load(MappingsAssembly);
   foreach (string file in Mappings)
   {
      cfg.AddResource(MappingsAssembly + "." + file, assembly);
   }
   Configure(cfg);
   ApplyCacheSettings(cfg);
}

 [[#variable58400e80]]void CreateSchema()
{
   new SchemaExport(cfg).Create(OutputDdl, true);
}

private void DropSchema()
{
   new SchemaExport(cfg).Drop(OutputDdl, true);
}

protected virtual void BuildSessionFactory()
{
   sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
   connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}

private void Cleanup()
{
    [[#variable58400640]]
   sessions = null;
   connectionProvider = null;
   lastOpenedSession = null;
   cfg = null;
}

public int ExecuteStatement(string sql)
{
   if (cfg == null)
   {
      cfg = new Configuration();
   }
   using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
   {
      IDbConnection conn = prov.GetConnection();
      try
      {
         using (IDbTransaction tran = conn.BeginTransaction())
            using (IDbCommand comm = conn.CreateCommand())
            {
               comm.CommandText = sql;
               comm.Transaction = tran;
               comm.CommandType = CommandType.Text;
               int result = comm.ExecuteNonQuery();
               tran.Commit();
               return result;
            }
      }
      finally
      {
         prov.CloseConnection(conn);
      }
   }
}

protected ISessionFactoryImplementor Sfi
{
   get
   {
      return sessions;
   }
}

protected virtual ISession OpenSession()
{
   lastOpenedSession = sessions.OpenSession();
   return lastOpenedSession;
}

protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
   lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
   return lastOpenedSession;
}

protected void ApplyCacheSettings(Configuration configuration)
{
   if (CacheConcurrencyStrategy == null)
   {
      return;
   }
   foreach (PersistentClass clazz in configuration.ClassMappings)
   {
      bool hasLob = false;
      foreach (Property prop in clazz.PropertyClosureIterator)
      {
         if (prop.Value.IsSimpleValue)
         {
            IType type = ((SimpleValue)prop.Value).Type;
            if (type == NHibernateUtil.BinaryBlob)
            {
               hasLob = true;
            }
         }
      }
      if ( !hasLob && !clazz.IsInherited)
      {
         configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
      }
   }
   foreach (Mapping.Collection coll in configuration.CollectionMappings)
   {
      configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
   }
}

#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
   return true;
}

 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#58400de0]]
"Test didn't clean up after itself. session closed: " + wasClosed + " database cleaned: " + wasCleaned + " connection closed: " + wereConnectionsClosed 
12[[#58400de0]]
"Test didn't clean up after itself" 
13[[#58400de0]]
"Test didn't clean up after itself" 
14[[#58400de0]]
"Test didn't clean up after itself" 
21[[#58400e80]]
protected virtual 
22[[#58400e80]]
private 
23[[#58400e80]]
private 
24[[#58400e80]]
private 
31[[#58400640]]
if (sessions != null)
{
   sessions.Close();
} 
32[[#58400640]]
sessions.Close(); 
33[[#58400640]]
sessions.Close(); 
34[[#58400640]]
sessions.Close();