Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24329
Modified Files:
BasicBinaryFixture.cs
Log Message:
Added some messesages to Asserts to make sure what is being tested (and
failing) is reported in an easy to read way.
Index: BasicBinaryFixture.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/BasicBinaryFixture.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BasicBinaryFixture.cs 29 Jun 2004 04:30:16 -0000 1.1
--- BasicBinaryFixture.cs 30 Jun 2004 13:29:49 -0000 1.2
***************
*** 11,15 ****
{
/// <summary>
! /// Summary description for BasicBinaryFixture.
/// </summary>
[TestFixture]
--- 11,15 ----
{
/// <summary>
! /// Tests for mapping a byte[] Property to a BinaryType.
/// </summary>
[TestFixture]
***************
*** 41,46 ****
Assert.IsNotNull(bcBinaryLoaded);
! Assert.AreEqual(null, bcBinary.DefaultSize);
! Assert.AreEqual(null, bcBinary.WithSize);
s.Delete(bcBinaryLoaded);
--- 41,46 ----
Assert.IsNotNull(bcBinaryLoaded);
! Assert.AreEqual(null, bcBinary.DefaultSize, "A property mapped as type=\"Byte[]\" with a null byte[] value was not saved & loaded as null");
! Assert.AreEqual(null, bcBinary.WithSize, "A property mapped as type=\"Byte[](length)\" with null byte[] value was not saved & loaded as null");
s.Delete(bcBinaryLoaded);
***************
*** 67,72 ****
Assert.IsNotNull(bcBinaryLoaded);
! Assert.AreEqual(0, bcBinary.DefaultSize.Length);
! Assert.AreEqual(0, bcBinary.WithSize.Length);
s.Delete(bcBinaryLoaded);
--- 67,72 ----
Assert.IsNotNull(bcBinaryLoaded);
! Assert.AreEqual(0, bcBinary.DefaultSize.Length, "A property mapped as type=\"Byte[]\" with a byte[0] value was not saved & loaded as byte[0]");
! Assert.AreEqual(0, bcBinary.WithSize.Length, "A property mapped as type=\"Byte[](length)\" with a byte[0] value was not saved & loaded as byte[0]");
s.Delete(bcBinaryLoaded);
***************
*** 78,86 ****
public void Insert()
{
! BasicBinary bcBinary = new BasicBinary();
! bcBinary.Id = 1;
!
! bcBinary.DefaultSize = GetByteArray(5);
! bcBinary.WithSize = GetByteArray(10);
ISession s = sessions.OpenSession();
--- 78,82 ----
public void Insert()
{
! BasicBinary bcBinary = Create(1);
ISession s = sessions.OpenSession();
***************
*** 104,107 ****
--- 100,158 ----
}
+ [Test]
+ public void Update()
+ {
+ BasicBinary bcBinary = Create(1);
+
+ ISession s = sessions.OpenSession();
+ s.Save(bcBinary);
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ bcBinary = (BasicBinary)s.Load(typeof(BasicBinary), 1);
+
+ bcBinary.DefaultSize = GetByteArray(15);
+
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ // make sure the update went through
+ bcBinary = (BasicBinary)s.Load(typeof(BasicBinary), 1);
+
+ // was DefaultSize updated
+ ObjectAssertion.AssertEquals( bcBinary.DefaultSize, GetByteArray(15) );
+ // WithSize should not have been updated
+ ObjectAssertion.AssertEquals( bcBinary.WithSize, GetByteArray(10) );
+
+ // lets modify WithSize
+ bcBinary.WithSize = GetByteArray(20);
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ bcBinary = (BasicBinary)s.Load(typeof(BasicBinary), 1);
+
+ // was DefaultSize not updated
+ ObjectAssertion.AssertEquals( bcBinary.DefaultSize, GetByteArray(15) );
+ ObjectAssertion.AssertEquals( bcBinary.WithSize, GetByteArray(20) );
+
+ s.Delete(bcBinary);
+ s.Flush();
+ s.Close();
+ }
+
+ private BasicBinary Create(int id)
+ {
+ BasicBinary bcBinary = new BasicBinary();
+ bcBinary.Id = id;
+
+ bcBinary.DefaultSize = GetByteArray(5);
+ bcBinary.WithSize = GetByteArray(10);
+
+ return bcBinary;
+ }
+
private byte[] GetByteArray(int value)
{
|