Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18283/NHibernate.Test/NHSpecificTest
Modified Files:
BasicClassFixture.cs
Added Files:
BasicBinaryFixture.cs
Log Message:
Moved BinaryProperties to their own class for smaller test fixtures.
Continued to work on FindByCriteria
Index: BasicClassFixture.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/BasicClassFixture.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BasicClassFixture.cs 9 Jun 2004 01:06:22 -0000 1.1
--- BasicClassFixture.cs 29 Jun 2004 04:30:16 -0000 1.2
***************
*** 71,93 ****
index++;
! // make sure the previous updates went through
! s[index] = sessions.OpenSession();
! t[index] = s[index].BeginTransaction();
!
! bc[index] = (BasicClass)s[index].Load(typeof(BasicClass), id);
! AssertPropertiesEqual(bc[index-1], bc[index]);
!
! // update the Binary property to make sure it picks up that it is dirty
! BinaryFormatter bf = new BinaryFormatter();
! MemoryStream stream = new MemoryStream();
! bf.Serialize(stream, 4);
! bc[index].BinaryProperty = stream.ToArray();
! s[index].Update(bc[index]);
!
! t[index].Commit();
! s[index].Close();
!
! index++;
!
// make sure the previous updates went through
s[index] = sessions.OpenSession();
--- 71,75 ----
index++;
!
// make sure the previous updates went through
s[index] = sessions.OpenSession();
***************
*** 861,865 ****
{
Assert.AreEqual(expected.Id, actual.Id, "Id");
- ObjectAssertion.AssertEquals(expected.BinaryProperty, actual.BinaryProperty);
Assert.AreEqual(expected.BooleanProperty, actual.BooleanProperty, "BooleanProperty");
Assert.AreEqual(expected.ByteProperty, actual.ByteProperty, "ByteProperty");
--- 843,846 ----
***************
*** 897,905 ****
basicClass.Id = id;
! BinaryFormatter bf = new BinaryFormatter();
! MemoryStream stream = new MemoryStream();
! bf.Serialize(stream, 5);
! basicClass.BinaryProperty = stream.ToArray();
!
basicClass.BooleanProperty = true;
basicClass.ByteProperty = Byte.MaxValue;
--- 878,882 ----
basicClass.Id = id;
!
basicClass.BooleanProperty = true;
basicClass.ByteProperty = Byte.MaxValue;
--- NEW FILE: BasicBinaryFixture.cs ---
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using NHibernate.DomainModel.NHSpecific;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest
{
/// <summary>
/// Summary description for BasicBinaryFixture.
/// </summary>
[TestFixture]
public class BasicBinaryFixture : TestCase
{
[SetUp]
public void SetUp()
{
ExportSchema( new string[] { "NHSpecific.BasicBinary.hbm.xml"}, true );
}
[Test]
public void InsertNull()
{
BasicBinary bcBinary = new BasicBinary();
bcBinary.Id = 1;
bcBinary.DefaultSize = null;
bcBinary.WithSize = null;
ISession s = sessions.OpenSession();
s.Save(bcBinary);
s.Flush();
s.Close();
s = sessions.OpenSession();
BasicBinary bcBinaryLoaded = (BasicBinary)s.Load(typeof(BasicBinary), 1);
Assert.IsNotNull(bcBinaryLoaded);
Assert.AreEqual(null, bcBinary.DefaultSize);
Assert.AreEqual(null, bcBinary.WithSize);
s.Delete(bcBinaryLoaded);
s.Flush();
s.Close();
}
[Test]
public void InsertZeroLength()
{
BasicBinary bcBinary = new BasicBinary();
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();
BasicBinary bcBinaryLoaded = (BasicBinary)s.Load(typeof(BasicBinary), 1);
Assert.IsNotNull(bcBinaryLoaded);
Assert.AreEqual(0, bcBinary.DefaultSize.Length);
Assert.AreEqual(0, bcBinary.WithSize.Length);
s.Delete(bcBinaryLoaded);
s.Flush();
s.Close();
}
[Test]
public void Insert()
{
BasicBinary bcBinary = new BasicBinary();
bcBinary.Id = 1;
bcBinary.DefaultSize = GetByteArray(5);
bcBinary.WithSize = GetByteArray(10);
ISession s = sessions.OpenSession();
s.Save(bcBinary);
s.Flush();
s.Close();
s = sessions.OpenSession();
BasicBinary bcBinaryLoaded = (BasicBinary)s.Load(typeof(BasicBinary), 1);
Assert.IsNotNull(bcBinaryLoaded);
Assert.IsFalse(bcBinary==bcBinaryLoaded);
ObjectAssertion.AssertEquals(bcBinary.DefaultSize, bcBinaryLoaded.DefaultSize);
ObjectAssertion.AssertEquals(bcBinary.WithSize, bcBinaryLoaded.WithSize);
s.Delete(bcBinaryLoaded);
s.Flush();
s.Close();
}
private byte[] GetByteArray(int value)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
bf.Serialize(stream, value);
return stream.ToArray();
}
}
}
|