From: Michael D. <mik...@us...> - 2004-12-30 16:25:30
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19437/src/NHibernate.Test/TypesTest Modified Files: BooleanTypeFixture.cs ByteTypeFixture.cs DecimalTypeFixture.cs GuidTypeFixture.cs PersistentEnumTypeFixture.cs Added Files: BooleanClass.cs BooleanClass.hbm.xml ByteClass.cs ByteClass.hbm.xml DecimalClass.cs DecimalClass.hbm.xml GuidClass.cs GuidClass.hbm.xml Removed Files: BaseTypeFixture.cs Log Message: Removed dependency on DotNetMock from the Test assembly. Modified the test that were dependant on DotNetMock. --- NEW FILE: GuidClass.hbm.xml --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ByteClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for ByteClass. /// </summary> public class ByteClass { int _id; byte _byteValue; public ByteClass() { } public int Id { get { return _id; } set { _id = value; } } public byte ByteValue { get { return _byteValue; } set { _byteValue = value; } } } } --- NEW FILE: BooleanClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for BooleanClass. /// </summary> public class BooleanClass { int _id; bool _booleanValue; public BooleanClass() { } public int Id { get { return _id; } set { _id = value; } } public bool BooleanValue { get {return _booleanValue;} set {_booleanValue = value;} } } } Index: GuidTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuidTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.3 --- GuidTypeFixture.cs 30 Dec 2004 16:25:19 -0000 1.4 *************** *** 1,4 **** using System; - using System.Data; using NHibernate.Type; --- 1,3 ---- *************** *** 11,75 **** /// </summary> [TestFixture] ! public class GuidTypeFixture : BaseTypeFixture { ! /// <summary> ! /// Test that Get(IDataReader, index) returns a boxed Guid value that is what ! /// we expect. ! /// </summary> ! [Test] ! public void Get() ! { ! NullableType type = NHibernate.Guid; ! ! Guid expected = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! ! // move to the first record ! reader.Read(); ! Guid actual = (Guid)type.Get(reader, GuidTypeColumnIndex); ! Assert.AreEqual(expected, actual); } ! [Test] ! public void EqualsTrue() { ! Guid lhs = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! Guid rhs = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! NullableType type = NHibernate.Guid; ! Assert.IsTrue(type.Equals(lhs, rhs)); } [Test] ! public void EqualsFalse() { Guid lhs = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! Guid rhs = new Guid("{11234567-abcd-abcd-abcd-0123456789ab}"); ! NullableType type = NHibernate.Guid; ! Assert.IsFalse(type.Equals(lhs, rhs)); } - /// <summary> - /// Test to make sure that a boxed Guid and a struct Guid compare the - /// same as two struct Guids. - /// </summary> [Test] ! public void EqualsWithSnapshot() { ! Guid busObjValue = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! object snapshotValue = busObjValue; ! NullableType type = NHibernate.Guid; ! Assert.IsTrue(type.Equals(busObjValue, snapshotValue)); ! // simulate the UI changing the busObjValue ! busObjValue = new Guid("{11234567-abcd-abcd-abcd-0123456789ab}"); ! Assert.IsFalse(type.Equals(busObjValue, snapshotValue)); ! } } } \ No newline at end of file --- 10,86 ---- /// </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 + /// is dirty. + /// </summary> [Test] ! public void Equals() { + GuidType type = (GuidType)NHibernate.Guid; + Guid lhs = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! Guid rhs = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! Assert.IsTrue( type.Equals( lhs, rhs ) ); ! rhs = new Guid("{11234567-abcd-abcd-abcd-0123456789ab}"); ! ! Assert.IsFalse( type.Equals( lhs, rhs ) ); ! } [Test] ! public void ReadWrite() { + Guid val = new Guid("{01234567-abcd-abcd-abcd-0123456789ab}"); ! GuidClass basic = new GuidClass(); ! basic.Id = 1; ! basic.GuidValue = val; ! ISession s = sessions.OpenSession(); ! s.Save(basic); ! s.Flush(); ! s.Close(); ! s = sessions.OpenSession(); ! basic = (GuidClass)s.Load( typeof(GuidClass), 1 ); ! Assert.AreEqual( val, basic.GuidValue ); + s.Delete( basic ); + s.Flush(); + s.Close(); + } } } \ No newline at end of file Index: DecimalTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/DecimalTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DecimalTypeFixture.cs 22 Mar 2004 04:34:47 -0000 1.2 --- DecimalTypeFixture.cs 30 Dec 2004 16:25:19 -0000 1.3 *************** *** 1,4 **** using System; - using System.Data; using NHibernate.Type; --- 1,3 ---- *************** *** 11,93 **** /// </summary> [TestFixture] ! public class DecimalTypeFixture : BaseTypeFixture { ! /// <summary> ! /// Test that two decimal fields that are exactly equal are returned ! /// as Equal by the DecimalType. ! /// </summary> ! [Test] ! public void Equals() { ! decimal lhs = 5.64351M; ! decimal rhs = 5.64351M; ! NullableType type = NHibernate.Decimal; ! Assert.IsTrue(type.Equals(lhs, rhs)); } ! /// <summary> ! /// Test that two decimal fields that are equal except one has a higher precision than ! /// the other one are returned as Equal by the DecimalType. ! /// </summary> ! [Test] ! public void EqualsWithDiffPrecision() { ! decimal lhs = 5.64351M; ! decimal rhs = 5.643510M; ! NullableType type = NHibernate.Decimal; ! Assert.IsTrue(type.Equals(lhs, rhs)); } /// <summary> ! /// Test that Get(IDataReader, index) returns a boxed Decimal value that is what ! /// we expect. /// </summary> - /// <remarks> - /// A Decimal variable holding <c>5.64531M</c> should be equal to a - /// <c>5.46531M</c> read from a IDataReader. - /// </remarks> [Test] ! public void Get() { ! NullableType type = TypeFactory.GetDecimalType(19, 5); ! decimal expected = 5.64351M; ! // move to the first record ! reader.Read(); ! ! decimal actualValue = (decimal)type.Get(reader, DecimalTypeColumnIndex); ! Assert.AreEqual(expected, actualValue); ! } - /// <summary> - /// Test that a System.Decimal created with an extra <c>0</c> will still be equal - /// to the System.Decimal without the last <c>0</c> - /// </summary> - /// <remarks> - /// A decimal variable initialized to <c>5.643510M</c> should be - /// equal to a <c>5.64351M</c> read from a IDataReader. - /// </remarks> [Test] ! public void GetWithDiffPrecision() { ! NullableType type = TypeFactory.GetDecimalType(19, 5); ! decimal expected = 5.643510M; ! ! // move to the first record ! reader.Read(); ! decimal actualValue = (decimal)type.Get(reader, DecimalTypeColumnIndex); ! Assert.AreEqual(expected, actualValue, "Expected double equals Actual"); ! ! ! } } } --- 10,88 ---- /// </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 ! /// as Equal by the DecimalType. /// </summary> [Test] ! public void Equals() { ! decimal lhs = 5.64351M; ! decimal rhs = 5.64351M; ! DecimalType type = (DecimalType)NHibernate.Decimal; ! Assert.IsTrue( type.Equals(lhs, rhs) ); ! // Test that two decimal fields that are equal except one has a higher precision than ! // the other one are returned as Equal by the DecimalType. ! rhs = 5.643510M; ! Assert.IsTrue(type.Equals(lhs, rhs)); } [Test] ! public void ReadWrite() { ! decimal expected = 5.64351M; ! DecimalClass basic = new DecimalClass(); ! basic.Id = 1; ! basic.DecimalValue = expected; ! ISession s = sessions.OpenSession(); ! s.Save(basic); ! s.Flush(); ! s.Close(); + s = sessions.OpenSession(); + basic = (DecimalClass)s.Load( typeof(DecimalClass), 1 ); + Assert.AreEqual( expected, basic.DecimalValue ); + Assert.AreEqual( 5.643510M, basic.DecimalValue ); + + s.Delete( basic ); + s.Flush(); + s.Close(); + } } } --- NEW FILE: GuidClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for GuidClass. /// </summary> public class GuidClass { int _id; Guid _guidValue; public GuidClass() { } public int Id { get { return _id; } set { _id = value; } } public Guid GuidValue { get { return _guidValue; } set { _guidValue = value; } } } } Index: BooleanTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/BooleanTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BooleanTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.2 --- BooleanTypeFixture.cs 30 Dec 2004 16:25:13 -0000 1.3 *************** *** 1,4 **** using System; - using System.Data; using NHibernate.Type; --- 1,3 ---- *************** *** 11,33 **** /// </summary> [TestFixture] ! public class BooleanTypeFixture : BaseTypeFixture { /// <summary> ! /// Test that Get(IDataReader, index) returns a boxed Boolean value that is what ! /// we expect. /// </summary> [Test] ! public void Get() { ! NullableType type = NHibernate.Boolean; ! bool expected = true; ! ! // move to the first record ! reader.Read(); ! bool actual = (bool)type.Get(reader, BooleanTypeColumnIndex); ! Assert.AreEqual(expected, actual); } } --- 10,78 ---- /// </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 ! /// is dirty. /// </summary> [Test] ! public void Equals() { ! BooleanType type = (BooleanType)NHibernate.Boolean; ! Assert.IsTrue( type.Equals( true, true ) ); ! Assert.IsTrue( type.Equals( false, false ) ); ! Assert.IsFalse( type.Equals( true, false ) ); ! } ! [Test] ! public void ReadWrite() ! { ! BooleanClass basic = new BooleanClass(); ! basic.Id = 1; ! basic.BooleanValue = true; ! ! ISession s = sessions.OpenSession(); ! s.Save(basic); ! s.Flush(); ! s.Close(); + s = sessions.OpenSession(); + basic = (BooleanClass)s.Load( typeof(BooleanClass), 1 ); + + Assert.AreEqual( true, basic.BooleanValue ); + + s.Delete( basic ); + s.Flush(); + s.Close(); } } --- NEW FILE: BooleanClass.hbm.xml --- (This appears to be a binary file; contents omitted.) --- NEW FILE: ByteClass.hbm.xml --- (This appears to be a binary file; contents omitted.) Index: ByteTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/ByteTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ByteTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.2 --- ByteTypeFixture.cs 30 Dec 2004 16:25:19 -0000 1.3 *************** *** 1,4 **** using System; - using System.Data; using NHibernate.Type; --- 1,3 ---- *************** *** 11,33 **** /// </summary> [TestFixture] ! public class ByteTypeFixture : BaseTypeFixture { /// <summary> ! /// Test that Get(IDataReader, index) returns a boxed Byte value that is what ! /// we expect. /// </summary> [Test] ! public void Get() { ! NullableType type = NHibernate.Byte; ! byte expected = 5; ! // move to the first record ! reader.Read(); ! byte actual = (byte)type.Get(reader, ByteTypeColumnIndex); ! Assert.AreEqual(expected, actual); } } --- 10,79 ---- /// </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 ! /// is dirty. /// </summary> [Test] ! public void Equals() { ! ByteType type = (ByteType)NHibernate.Byte; ! ! Assert.IsTrue( type.Equals( (byte)5, (byte)5 ) ); ! Assert.IsFalse( type.Equals( (byte)5, (byte)6 ) ); ! ! } ! [Test] ! public void ReadWrite() ! { ! ByteClass basic = new ByteClass(); ! basic.Id = 1; ! basic.ByteValue = (byte)43; ! ISession s = sessions.OpenSession(); ! s.Save(basic); ! s.Flush(); ! s.Close(); + s = sessions.OpenSession(); + basic = (ByteClass)s.Load( typeof(ByteClass), 1 ); + + Assert.AreEqual( (byte)43, basic.ByteValue ); + + s.Delete( basic ); + s.Flush(); + s.Close(); } } --- NEW FILE: DecimalClass.hbm.xml --- (This appears to be a binary file; contents omitted.) --- BaseTypeFixture.cs DELETED --- Index: PersistentEnumTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PersistentEnumTypeFixture.cs 28 Apr 2004 14:16:18 -0000 1.1 --- PersistentEnumTypeFixture.cs 30 Dec 2004 16:25:19 -0000 1.2 *************** *** 26,30 **** /// </summary> [TestFixture] ! public class PersistentEnumTypeFixture : BaseTypeFixture { [Test] --- 26,30 ---- /// </summary> [TestFixture] ! public class PersistentEnumTypeFixture { [Test] --- NEW FILE: DecimalClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for DecimalClass. /// </summary> public class DecimalClass { int _id; decimal _decimalValue; public DecimalClass() { } public int Id { get { return _id; } set { _id = value; } } public decimal DecimalValue { get {return _decimalValue;} set {_decimalValue = value;} } } } |