Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ProxyInterface
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11226/src/NHibernate.Test/ProxyInterface
Modified Files:
CastleProxyFixture.cs
Log Message:
Fixed more session leaks in tests
Index: CastleProxyFixture.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ProxyInterface/CastleProxyFixture.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CastleProxyFixture.cs 5 May 2005 19:28:03 -0000 1.3
--- CastleProxyFixture.cs 5 May 2005 20:46:56 -0000 1.4
***************
*** 41,44 ****
--- 41,61 ----
}
+ private void SerializeAndDeserialize(ref ISession s)
+ {
+ // Serialize the session
+ using( Stream stream = new MemoryStream() )
+ {
+ IFormatter formatter = new BinaryFormatter( );
+ formatter.Serialize(stream, s);
+
+ // Close the original session
+ s.Close();
+
+ // Deserialize the session
+ stream.Position = 0;
+ s = (ISession)formatter.Deserialize(stream);
+ }
+ }
+
[Test]
public void ProxySerialize()
***************
*** 56,79 ****
Assert.AreEqual( 1, ap.Id );
s.Disconnect();
!
! // serialize and then deserialize the session.
! Stream stream = new MemoryStream();
! IFormatter formatter = new BinaryFormatter( );
! formatter.Serialize(stream, s);
! stream.Position = 0;
! s = (ISession)formatter.Deserialize(stream);
! stream.Close();
s.Reconnect();
s.Disconnect();
!
// serialize and then deserialize the session again - make sure Castle.DynamicProxy
// has no problem with serializing two times - earlier versions of it did.
! stream = new MemoryStream();
! formatter = new BinaryFormatter( );
! formatter.Serialize(stream, s);
! stream.Position = 0;
! s = (ISession)formatter.Deserialize(stream);
! stream.Close();
s.Close();
--- 73,85 ----
Assert.AreEqual( 1, ap.Id );
s.Disconnect();
!
! SerializeAndDeserialize(ref s);
s.Reconnect();
s.Disconnect();
!
// serialize and then deserialize the session again - make sure Castle.DynamicProxy
// has no problem with serializing two times - earlier versions of it did.
! SerializeAndDeserialize(ref s);
s.Close();
***************
*** 88,99 ****
Assert.AreEqual( 5, notThere.Id );
s.Disconnect();
!
// serialize and then deserialize the session.
! Stream stream = new MemoryStream();
! IFormatter formatter = new BinaryFormatter( );
! formatter.Serialize(stream, s);
! stream.Position = 0;
! s = (ISession)formatter.Deserialize(stream);
! stream.Close();
Assert.IsNotNull( s.Load( typeof(CastleProxyImpl), 5 ), "should be proxy - even though it doesn't exists in db" );
--- 94,100 ----
Assert.AreEqual( 5, notThere.Id );
s.Disconnect();
!
// serialize and then deserialize the session.
! SerializeAndDeserialize(ref s);
Assert.IsNotNull( s.Load( typeof(CastleProxyImpl), 5 ), "should be proxy - even though it doesn't exists in db" );
|