Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25629/NHibernate.Test
Modified Files:
FooBarTest.cs
Log Message:
Implemented more tests.
Index: FooBarTest.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** FooBarTest.cs 7 Jul 2004 21:31:07 -0000 1.40
--- FooBarTest.cs 8 Jul 2004 00:22:54 -0000 1.41
***************
*** 1663,1667 ****
[Test]
- //[Ignore("Test not written yet.")]
public void RecursiveLoad()
{
--- 1663,1666 ----
***************
*** 1699,1706 ****
s.Flush();
s.Close();
! // TODO: resume here
! // s = sessions.OpenSession();
! // enumer = s.Enumerable("from g in class NHibernate.DomainModel.Glarch order by g.Order asc").GetEnumerator();
! // while (
}
--- 1698,1773 ----
s.Flush();
s.Close();
!
! s = sessions.OpenSession();
! enumer = s.Enumerable("from g in class NHibernate.DomainModel.Glarch order by g.Order asc").GetEnumerator();
! while ( enumer.MoveNext() )
! {
! GlarchProxy g = (GlarchProxy)enumer.Current;
! Assert.IsNotNull( g, "not null");
! // no equiv in .net - so ran a delete query
! // iter.remove();
! }
!
! s.Delete("from NHibernate.DomainModel.Glarch as g");
! s.Flush();
! s.Close();
!
! // same thing bug using polymorphic class (no optimization possible)
! s = sessions.OpenSession();
! FooProxy flast = new Bar();
! s.Save(flast);
! for( int i=0; i<5; i++ )
! {
! FooProxy foo = new Bar();
! s.Save(foo);
! flast.TheFoo = foo;
! flast = flast.TheFoo;
! flast.String = "foo" + (i+1);
! }
!
! enumer = s.Enumerable("from foo in class NHibernate.DomainModel.Foo").GetEnumerator();
! while( enumer.MoveNext() )
! {
! object obj = enumer.Current;
! }
!
! list = s.Find("from foo in class NHibernate.DomainModel.Foo");
! Assert.AreEqual( 6, list.Count, "recursive find");
! s.Flush();
! s.Close();
!
! s = sessions.OpenSession();
! list = s.Find("from foo in class NHibernate.DomainModel.Foo");
! Assert.AreEqual( 6, list.Count, "recursive iter" );
! enumer = list.GetEnumerator();
! while( enumer.MoveNext() )
! {
! Assert.IsTrue( enumer.Current is BarProxy, "polymorphic recursive load" );
! }
! s.Flush();
! s.Close();
!
! s = sessions.OpenSession();
! enumer = s.Enumerable("from foo in class NHibernate.DomainModel.Foo order by foo.String asc").GetEnumerator();
! string currentString = String.Empty;
!
! while( enumer.MoveNext() )
! {
!
! BarProxy bar = (BarProxy)enumer.Current;
! string theString = bar.String;
! Assert.IsNotNull( bar, "not null");
! if(currentString!=String.Empty)
! {
! Assert.IsTrue( theString.CompareTo(currentString) >= 0 , "not in asc order" );
! }
! currentString = theString;
! // no equiv in .net - so made a hql delete
! // iter.remove();
! }
!
! s.Delete("from NHibernate.DomainModel.Foo as foo");
! s.Flush();
! s.Close();
}
***************
*** 1760,1766 ****
[Test]
- [Ignore("Test not written yet.")]
public void LazyCollections()
{
}
--- 1827,1874 ----
[Test]
public void LazyCollections()
{
+ ISession s = sessions.OpenSession();
+ Qux q = new Qux();
+ s.Save(q);
+ s.Flush();
+ s.Close();
+
+ s = sessions.OpenSession();
+ q = (Qux)s.Load( typeof(Qux), q.Key );
+ s.Flush();
+ s.Close();
+
+ // two exceptions are supposed to occur:")
+ bool ok = false;
+ try
+ {
+ int i = q.MoreFums.Count;
+ }
+ catch (LazyInitializationException lie)
+ {
+ System.Diagnostics.Debug.WriteLine("caught expected " + lie.ToString());
+ ok = true;
+ }
+ Assert.IsTrue( ok, "lazy collection with one-to-many" );
+
+ ok = false;
+ try
+ {
+ int j = q.Fums.Count;
+ }
+ catch (LazyInitializationException lie)
+ {
+ System.Diagnostics.Debug.WriteLine("caught expected " + lie.ToString());
+ ok = true;
+ }
+
+ Assert.IsTrue( ok, "lazy collection with many-to-many" );
+
+ s = sessions.OpenSession();
+ q = (Qux)s.Load( typeof(Qux), q.Key );
+ s.Delete(q);
+ s.Flush();
+ s.Close();
}
|