Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv344/src/NHibernate.Test/TypesTest Modified Files: BooleanTypeFixture.cs ByteTypeFixture.cs GuidTypeFixture.cs Added Files: BinaryBlobClass.cs BinaryBlobClass.hbm.xml BinaryBlobTypeFixture.cs BinaryClass.cs BinaryClass.hbm.xml BinaryTypeFixture.cs DoubleClass.cs DoubleClass.hbm.xml DoubleTypeFixture.cs StringClobClass.cs StringClobClass.hbm.xml StringClobTypeFixture.cs Log Message: Moved classes out of NHSpecific and into appropriate folder in Test project. Index: GuidTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/GuidTypeFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuidTypeFixture.cs 19 May 2004 03:31:11 -0000 1.2 --- GuidTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.3 *************** *** 13,20 **** public class GuidTypeFixture : BaseTypeFixture { - public GuidTypeFixture() - { - } - /// <summary> /// Test that Get(IDataReader, index) returns a boxed Guid value that is what --- 13,16 ---- Index: BooleanTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/BooleanTypeFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BooleanTypeFixture.cs 22 Mar 2004 04:34:47 -0000 1.1 --- BooleanTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.2 *************** *** 13,20 **** public class BooleanTypeFixture : BaseTypeFixture { - public BooleanTypeFixture() - { - } - /// <summary> /// Test that Get(IDataReader, index) returns a boxed Boolean value that is what --- 13,16 ---- --- NEW FILE: BinaryBlobClass.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.TypesTest.BinaryBlobClass, NHibernate.Test" table="bim" > <id name="Id" type="Int32"> <generator class="hilo" /> </id> <!-- setting it to 100000 to get past the length that most dialects can hold in just a plain var binary column --> <property name="BinaryBlob" column="blob_" type="BinaryBlob" length="100000"/> </class> </hibernate-mapping> --- NEW FILE: BinaryTypeFixture.cs --- using System; using System.Collections; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using NHibernate; using NHibernate.Type; using NUnit.Framework; namespace NHibernate.Test.TypesTest { /// <summary> /// Tests for mapping a byte[] Property to a BinaryType. /// </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 /// is dirty. /// </summary> [Test] public void Equals() { BinaryType type = (BinaryType)NHibernate.Binary; byte[] expected = System.Text.Encoding.UTF8.GetBytes("ghij1`23%$"); byte[] expectedClone = System.Text.Encoding.UTF8.GetBytes("ghij1`23%$"); Assert.IsTrue( type.Equals( expected, expected ) ); Assert.IsTrue( type.Equals( expected, expectedClone ) ); Assert.IsFalse( type.Equals( expected, GetByteArray( 15 ) ) ); } /// <summary> /// Certain drivers (ie - Oralce) don't handle writing and reading null byte[] /// to and from the db consistently. Verify if this driver does. /// </summary> [Test] public void InsertNull() { BinaryClass bcBinary = new BinaryClass(); bcBinary.Id = 1; bcBinary.DefaultSize = null; bcBinary.WithSize = null; ISession s = sessions.OpenSession(); s.Save(bcBinary); s.Flush(); s.Close(); s = sessions.OpenSession(); BinaryClass bcBinaryLoaded = (BinaryClass)s.Load( typeof(BinaryClass), 1 ); Assert.IsNotNull(bcBinaryLoaded); Assert.AreEqual(null, bcBinaryLoaded.DefaultSize, "A property mapped as type=\"Byte[]\" with a null byte[] value was not saved & loaded as null"); Assert.AreEqual(null, bcBinaryLoaded.WithSize, "A property mapped as type=\"Byte[](length)\" with null byte[] value was not saved & loaded as null"); s.Delete(bcBinaryLoaded); s.Flush(); s.Close(); } /// <summary> /// Certain drivers (ie - Oralce) don't handle writing and reading byte[0] /// to and from the db consistently. Verify if this driver does. /// </summary> [Test] public void InsertZeroLength() { BinaryClass bcBinary = new BinaryClass(); bcBinary.Id = 1; bcBinary.DefaultSize = new byte[0]; bcBinary.WithSize = new byte[0]; ISession s = sessions.OpenSession(); s.Save(bcBinary); s.Flush(); s.Close(); s = sessions.OpenSession(); BinaryClass bcBinaryLoaded = (BinaryClass)s.Load( typeof(BinaryClass), 1 ); Assert.IsNotNull(bcBinaryLoaded); Assert.AreEqual(0, bcBinaryLoaded.DefaultSize.Length, "A property mapped as type=\"Byte[]\" with a byte[0] value was not saved & loaded as byte[0]"); Assert.AreEqual(0, bcBinaryLoaded.WithSize.Length, "A property mapped as type=\"Byte[](length)\" with a byte[0] value was not saved & loaded as byte[0]"); s.Delete(bcBinaryLoaded); s.Flush(); s.Close(); } /// <summary> /// Test the setting of values in Parameters and the reading of the /// values out of the IDataReader. /// </summary> [Test] public void ReadWrite() { BinaryClass bcBinary = Create( 1 ); BinaryClass expected = Create( 1 ); ISession s = sessions.OpenSession(); s.Save( bcBinary ); s.Flush(); s.Close(); s = sessions.OpenSession(); bcBinary = (BinaryClass)s.Load( typeof(BinaryClass), 1 ); // make sure what was saved was expected ObjectAssert.AreEqual( expected.DefaultSize, bcBinary.DefaultSize ); ObjectAssert.AreEqual( expected.WithSize, bcBinary.WithSize ); s.Delete( bcBinary ); s.Flush(); s.Close(); } private BinaryClass Create(int id) { BinaryClass bcBinary = new BinaryClass(); bcBinary.Id = id; bcBinary.DefaultSize = GetByteArray(5); bcBinary.WithSize = GetByteArray(10); return bcBinary; } private byte[] GetByteArray(int value) { BinaryFormatter bf = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); bf.Serialize(stream, value); return stream.ToArray(); } } } --- NEW FILE: StringClobTypeFixture.cs --- using System; using NUnit.Framework; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for StringClobTypeFixture. /// </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() { ISession s = sessions.OpenSession(); StringClobClass b = new StringClobClass(); b.StringClob = "foo/bar/baz"; s.Save(b); s.Flush(); s.Close(); s = sessions.OpenSession(); b = (StringClobClass)s.Load( typeof(StringClobClass), b.Id ); Assert.AreEqual( "foo/bar/baz", b.StringClob ); s.Delete( b ); s.Flush(); s.Close(); } } } --- NEW FILE: DoubleClass.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.TypesTest.DoubleClass, NHibernate.Test" table="bc_dub"> <id name="Id" column="id"> <generator class="assigned" /> </id> <property name="DoubleValue" type="Double" column="doub"/> </class> </hibernate-mapping> --- NEW FILE: StringClobClass.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.TypesTest.StringClobClass, NHibernate.Test" table="sclob" > <id name="Id" type="Int32"> <generator class="hilo" /> </id> <!-- setting it to 100000 to get past the length that most dialects can hold in just a plain var binary column --> <property name="StringClob" column="clob_" type="StringClob" length="100000"/> </class> </hibernate-mapping> --- NEW FILE: DoubleTypeFixture.cs --- using System; using NHibernate.Type; using NHibernate.Test.TypesTest; using NUnit.Framework; namespace NHibernate.Test.TypesTest { /// <summary> /// Tests for mapping a Double Property to a database field. /// </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 ) { _values[0] = 1.5e20; _values[1] = 1.2e-20; } else { _values[0] = 1.5e35; _values[1] = 1.2e-35; } } [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() { DoubleType type = (DoubleType)NHibernate.Double; Assert.IsTrue( type.Equals( 1.5e20, 1.5e20 ) ); Assert.IsFalse( type.Equals( 1.5e20, 1.4e20 ) ); } [Test] public void ReadWrite() { DoubleClass basic = new DoubleClass(); basic.Id = 1; basic.DoubleValue = _values[0]; ISession s = sessions.OpenSession(); s.Save(basic); s.Flush(); s.Close(); s = sessions.OpenSession(); basic = (DoubleClass)s.Load( typeof(DoubleClass), 1 ); Assert.AreEqual( _values[0], basic.DoubleValue ); s.Delete( basic ); s.Flush(); s.Close(); } } } --- NEW FILE: BinaryBlobTypeFixture.cs --- using System; using NHibernate; using NUnit.Framework; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for BinaryBlobTypeFixture. /// </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() { ISession s = sessions.OpenSession(); BinaryBlobClass b = new BinaryBlobClass(); b.BinaryBlob = System.Text.UnicodeEncoding.UTF8.GetBytes("foo/bar/baz"); s.Save(b); s.Flush(); s.Close(); s = sessions.OpenSession(); b = (BinaryBlobClass)s.Load( typeof(BinaryBlobClass), b.Id ); ObjectAssert.AreEqual( System.Text.UnicodeEncoding.UTF8.GetBytes("foo/bar/baz") , b.BinaryBlob ); s.Delete( b ); s.Flush(); s.Close(); } } } --- NEW FILE: DoubleClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for DoubleClass. /// </summary> public class DoubleClass { int _id; Double _doubleValue; public DoubleClass() { } public int Id { get { return _id; } set { _id = value; } } public double DoubleValue { get {return _doubleValue;} set {_doubleValue = value;} } } } Index: ByteTypeFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/TypesTest/ByteTypeFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ByteTypeFixture.cs 22 Mar 2004 04:34:47 -0000 1.1 --- ByteTypeFixture.cs 12 Dec 2004 07:18:27 -0000 1.2 *************** *** 13,20 **** public class ByteTypeFixture : BaseTypeFixture { - public ByteTypeFixture() - { - } - /// <summary> /// Test that Get(IDataReader, index) returns a boxed Byte value that is what --- 13,16 ---- --- NEW FILE: BinaryClass.hbm.xml --- <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"> <class name="NHibernate.Test.TypesTest.BinaryClass, NHibernate.Test" table="bc_bin"> <id name="Id" column="id"> <generator class="assigned" /> </id> <property name="DefaultSize" column="bin_def"/> <property name="WithSize" type="Byte[](2048880)" column="bin_size" /> </class> </hibernate-mapping> --- NEW FILE: BinaryBlobClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for BinaryBlobClass. /// </summary> public class BinaryBlobClass { private int _id; private byte[] _blob; private string _clob; public int Id { get { return _id; } set { _id = value; } } public byte[] BinaryBlob { get { return _blob; } set { _blob = value; } } } } --- NEW FILE: BinaryClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for BinaryClass. /// </summary> public class BinaryClass { int _id; byte[] _defaultSize; byte[] _withSize; public BinaryClass() { } public int Id { get { return _id; } set { _id = value; } } public byte[] DefaultSize { get {return _defaultSize;} set {_defaultSize = value;} } public byte[] WithSize { get {return _withSize;} set {_withSize = value;} } } } --- NEW FILE: StringClobClass.cs --- using System; namespace NHibernate.Test.TypesTest { /// <summary> /// Summary description for StringClobClass. /// </summary> public class StringClobClass { private int _id; private string _clob; public int Id { get { return _id; } set { _id = value; } } public string StringClob { get { return _clob; } set { _clob = value; } } } } |