From: Sergey K. <jus...@us...> - 2005-05-06 23:41:30
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6714/src/NHibernate.Test/TypesTest Modified Files: BinaryBlobTypeFixture.cs BinaryTypeFixture.cs BooleanTypeFixture.cs ByteTypeFixture.cs DecimalTypeFixture.cs DoubleTypeFixture.cs GuidTypeFixture.cs StringClobTypeFixture.cs Added Files: TypeFixtureBase.cs Log Message: Major TestCase refactoring: - schema is now always set up in TestCase.TestFixtureSetUp and dropped in TestCase.TestFixtureTearDown - added property Mappings and MappingsAssembly to specify mappings declaratively instead of manually calling SchemaExport ! all tests now have to clean up the database after themselves! This is checked in TestCase.TearDown. - test cases not cleaning up the database were fixed - SetUp and TearDown are non-virtual, test writers are supposed to override OnSetUp and OnTearDown instead. - Added TypeFixtureBase for type-related fixtures to reduce code duplication somewhat These modifications sped up tests 10 times on my machine. Index: DoubleTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/DoubleTypeFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DoubleTypeFixture.cs 5 May 2005 19:28:04 -0000 1.3 --- DoubleTypeFixture.cs 6 May 2005 23:41:20 -0000 1.4 *************** *** 12,30 **** /// </summary> [TestFixture] ! public class DoubleTypeFixture : TestCase { double[] _values = new double[2]; ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() { ! ExportSchema( new string[] { "TypesTest.DoubleClass.hbm.xml"}, true, "NHibernate.Test" ); } ! [SetUp] ! public void SetUp() { if( dialect is Dialect.OracleDialect ) { --- 12,27 ---- /// </summary> [TestFixture] ! public class DoubleTypeFixture : TypeFixtureBase { double[] _values = new double[2]; ! protected override string TypeName { ! get { return "Double"; } } ! protected override void OnSetUp() { + base.OnSetUp (); if( dialect is Dialect.OracleDialect ) { *************** *** 39,56 **** } - [TearDown] - public override void TearDown() - { - // do nothing except not let the base TearDown get called - } - - [TestFixtureTearDown] - public void TestFixtureTearDown() - { - base.TearDown(); - } - - #endregion - /// <summary> /// Verify Equals will correctly determine when the property --- 36,39 ---- Index: BinaryBlobTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/BinaryBlobTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BinaryBlobTypeFixture.cs 5 May 2005 19:28:04 -0000 1.2 --- BinaryBlobTypeFixture.cs 6 May 2005 23:41:20 -0000 1.3 *************** *** 11,46 **** /// </summary> [TestFixture] ! public class BinaryBlobTypeFixture : TestCase { ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.BinaryBlobClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! //base.TearDown (); ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! // only do this at the end of the test fixture ! base.TearDown(); } - #endregion - [Test] public void ReadWrite() --- 11,21 ---- /// </summary> [TestFixture] ! public class BinaryBlobTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "BinaryBlob"; } } [Test] public void ReadWrite() Index: GuidTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GuidTypeFixture.cs 5 May 2005 19:28:04 -0000 1.6 --- GuidTypeFixture.cs 6 May 2005 23:41:20 -0000 1.7 *************** *** 10,44 **** /// </summary> [TestFixture] ! public class GuidTypeFixture : TestCase { ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.GuidClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! // do nothing except not let the base TearDown get called ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! base.TearDown(); } - #endregion - /// <summary> /// Verify Equals will correctly determine when the property --- 10,20 ---- /// </summary> [TestFixture] ! public class GuidTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "Guid"; } } /// <summary> /// Verify Equals will correctly determine when the property *************** *** 57,61 **** Assert.IsFalse( type.Equals( lhs, rhs ) ); - } --- 33,36 ---- *************** *** 84,86 **** } } ! } \ No newline at end of file --- 59,61 ---- } } ! } Index: DecimalTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/DecimalTypeFixture.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DecimalTypeFixture.cs 5 May 2005 19:28:04 -0000 1.6 --- DecimalTypeFixture.cs 6 May 2005 23:41:20 -0000 1.7 *************** *** 10,45 **** /// </summary> [TestFixture] ! public class DecimalTypeFixture : TestCase { ! ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.DecimalClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! // do nothing except not let the base TearDown get called ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! base.TearDown(); } - #endregion - /// <summary> /// Test that two decimal fields that are exactly equal are returned --- 10,20 ---- /// </summary> [TestFixture] ! public class DecimalTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "Decimal"; } } /// <summary> /// Test that two decimal fields that are exactly equal are returned --- NEW FILE: TypeFixtureBase.cs --- using System; using System.Collections; namespace NHibernate.Test.TypesTest { /// <summary> /// Base class for fixtures testing individual types, created to avoid /// code duplication in derived classes. It assumes that the fixture /// uses mapping file named "(TypeName)Class.hbm.xml" placed in TypesTest /// directory in NHibernate.Test assembly. /// </summary> public abstract class TypeFixtureBase : TestCase { protected abstract string TypeName { get; } protected override string MappingsAssembly { get { return "NHibernate.Test"; } } protected override System.Collections.IList Mappings { get { return new string[] { String.Format( "TypesTest.{0}Class.hbm.xml", TypeName ) }; } } } } Index: BooleanTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/BooleanTypeFixture.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BooleanTypeFixture.cs 5 May 2005 19:28:04 -0000 1.5 --- BooleanTypeFixture.cs 6 May 2005 23:41:20 -0000 1.6 *************** *** 10,44 **** /// </summary> [TestFixture] ! public class BooleanTypeFixture : TestCase { ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.BooleanClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! // do nothing except not let the base TearDown get called ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! base.TearDown(); } - #endregion - /// <summary> /// Verify Equals will correctly determine when the property --- 10,20 ---- /// </summary> [TestFixture] ! public class BooleanTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "Boolean"; } } /// <summary> /// Verify Equals will correctly determine when the property Index: ByteTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/ByteTypeFixture.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ByteTypeFixture.cs 5 May 2005 19:28:04 -0000 1.5 --- ByteTypeFixture.cs 6 May 2005 23:41:20 -0000 1.6 *************** *** 10,44 **** /// </summary> [TestFixture] ! public class ByteTypeFixture : TestCase { ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.ByteClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! // do nothing except not let the base TearDown get called ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! base.TearDown(); } - #endregion - /// <summary> /// Verify Equals will correctly determine when the property --- 10,20 ---- /// </summary> [TestFixture] ! public class ByteTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "Byte"; } } /// <summary> /// Verify Equals will correctly determine when the property *************** *** 52,56 **** Assert.IsTrue( type.Equals( (byte)5, (byte)5 ) ); Assert.IsFalse( type.Equals( (byte)5, (byte)6 ) ); - } --- 28,31 ---- *************** *** 58,62 **** public void ReadWrite() { - ByteClass basic = new ByteClass(); basic.Id = 1; --- 33,36 ---- Index: BinaryTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/BinaryTypeFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BinaryTypeFixture.cs 5 May 2005 19:28:04 -0000 1.3 --- BinaryTypeFixture.cs 6 May 2005 23:41:20 -0000 1.4 *************** *** 16,52 **** /// </summary> [TestFixture] ! public class BinaryTypeFixture : TestCase { ! ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.BinaryClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! //base.TearDown (); ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! // only do this at the end of the test fixture ! base.TearDown(); } - #endregion - /// <summary> /// Verify Equals will correctly determine when the property --- 16,26 ---- /// </summary> [TestFixture] ! public class BinaryTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "Binary"; } } /// <summary> /// Verify Equals will correctly determine when the property Index: StringClobTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/StringClobTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringClobTypeFixture.cs 5 May 2005 19:28:21 -0000 1.2 --- StringClobTypeFixture.cs 6 May 2005 23:41:20 -0000 1.3 *************** *** 9,44 **** /// </summary> [TestFixture] ! public class StringClobTypeFixture : TestCase { ! #region NUnit.Framework.TestFixture Members ! ! [TestFixtureSetUp] ! public void TestFixtureSetUp() ! { ! ExportSchema( new string[] { "TypesTest.StringClobClass.hbm.xml"}, true, "NHibernate.Test" ); ! } ! ! [SetUp] ! public void SetUp() ! { ! // there are test in here where we don't need to resetup the ! // tables - so only set the tables up once ! } ! ! [TearDown] ! public override void TearDown() ! { ! //base.TearDown (); ! } ! ! [TestFixtureTearDown] ! public void TestFixtureTearDown() { ! // only do this at the end of the test fixture ! base.TearDown(); } - #endregion - [Test] public void ReadWrite() --- 9,19 ---- /// </summary> [TestFixture] ! public class StringClobTypeFixture : TypeFixtureBase { ! protected override string TypeName { ! get { return "StringClob"; } } [Test] public void ReadWrite() |