From: Michael D. <mik...@us...> - 2004-04-07 21:37:23
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2572/NHibernate.Test Modified Files: ABCProxyTest.cs ABCTest.cs TestCase.cs Log Message: Added a method to execute DropSchema so all test can remove their tables in a [TearDown] method instead of needing the ExecuteStatement method. Index: TestCase.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TestCase.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestCase.cs 6 Apr 2004 13:36:18 -0000 1.4 --- TestCase.cs 7 Apr 2004 21:24:21 -0000 1.5 *************** *** 14,17 **** --- 14,18 ---- public abstract class TestCase { + protected Configuration cfg; protected ISessionFactory sessions; protected Dialect.Dialect dialect; *************** *** 24,28 **** public void ExportSchema(string[] files, bool exportSchema) { ! Configuration cfg = new Configuration(); for (int i=0; i<files.Length; i++) --- 25,29 ---- public void ExportSchema(string[] files, bool exportSchema) { ! cfg = new Configuration(); for (int i=0; i<files.Length; i++) *************** *** 38,73 **** } ! public void ExecuteStatement(string sql) { ! ExecuteStatement(sql, true); } - public void ExecuteStatement(string sql, bool error) - { - SqlConnection conn = null; - SqlTransaction tran = null; - try - { - conn = new SqlConnection("Server=localhost;initial catalog=nhibernate;User ID=someuser;Password=somepwd"); - conn.Open(); - tran = conn.BeginTransaction(); - System.Data.SqlClient.SqlCommand comm = conn.CreateCommand(); - comm.CommandText = sql; - comm.Transaction = tran; - comm.CommandType = CommandType.Text; - comm.ExecuteNonQuery(); - tran.Commit(); - } - catch - { - tran.Rollback(); - if (error) - throw; - } - finally - { - conn.Close(); - } - } } } --- 39,47 ---- } ! public void DropSchema(string[] files) { ! new SchemaExport(cfg).Drop(true, true); } } } Index: ABCProxyTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ABCProxyTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ABCProxyTest.cs 6 Apr 2004 13:36:18 -0000 1.2 --- ABCProxyTest.cs 7 Apr 2004 21:24:21 -0000 1.3 *************** *** 13,22 **** public void SetUp() { - ExecuteStatement("drop table D", false); - ExecuteStatement("drop table A", false); - ExecuteStatement("drop table map", false); ExportSchema(new string[] { "ABCProxy.hbm.xml"}); } [Test] [Ignore("Test will fail because of proxy initalization problems")] --- 13,25 ---- public void SetUp() { ExportSchema(new string[] { "ABCProxy.hbm.xml"}); } + [TearDown] + public void TearDown() + { + DropSchema(new string[] { "ABCProxy.hbm.xml"}); + } + [Test] [Ignore("Test will fail because of proxy initalization problems")] Index: ABCTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ABCTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ABCTest.cs 6 Apr 2004 13:36:18 -0000 1.2 --- ABCTest.cs 7 Apr 2004 21:24:21 -0000 1.3 *************** *** 16,25 **** public void SetUp() { - ExecuteStatement("drop table D", false); - ExecuteStatement("drop table A", false); - ExecuteStatement("drop table map", false); ExportSchema(new string[] { "ABC.hbm.xml"}); } [Test] public void Subclassing() --- 16,28 ---- public void SetUp() { ExportSchema(new string[] { "ABC.hbm.xml"}); } + [TearDown] + public void TearDown() + { + DropSchema(new string[] { "ABC.hbm.xml"}); + } + [Test] public void Subclassing() |