From: Sergey K. <jus...@us...> - 2005-02-16 20:14:56
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30719/src/NHibernate.Test Modified Files: FooBarTest.cs Log Message: Renamed PersistentCollection.ForceLoad to ForceInitialization, in accordance with H2.1 Added non-lazy collections handling which fixed a bug when non-lazy collections didn't initialize. Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** FooBarTest.cs 24 Jan 2005 03:44:48 -0000 1.82 --- FooBarTest.cs 16 Feb 2005 20:14:14 -0000 1.83 *************** *** 592,596 **** "from Bar bar " + "inner join bar.Baz baz inner join baz.CascadingBars b " + ! "where bar.Name like 'bar%'" ); list = q.List(); Assert.AreEqual( 1, list.Count ); --- 592,596 ---- "from Bar bar " + "inner join bar.Baz baz inner join baz.CascadingBars b " + ! "where bar.Name ilike 'bar%'" ); list = q.List(); Assert.AreEqual( 1, list.Count ); *************** *** 2785,2792 **** t.Commit(); } ! catch (Exception e) { t.Rollback(); ! throw e; } finally --- 2785,2792 ---- t.Commit(); } ! catch (Exception) { t.Rollback(); ! throw; } finally *************** *** 2823,2830 **** t.Commit(); } ! catch(Exception e) { t.Rollback(); ! throw e; } finally --- 2823,2830 ---- t.Commit(); } ! catch(Exception) { t.Rollback(); ! throw; } finally *************** *** 3644,3648 **** enumer.MoveNext(); Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); // many-to-many outer-join="true" ! } enumer = baz.FooSet.GetEnumerator(); --- 3644,3648 ---- enumer.MoveNext(); Assert.IsFalse( enumer.Current is Proxy.INHibernateProxy ); // many-to-many outer-join="true" ! } enumer = baz.FooSet.GetEnumerator(); *************** *** 3685,3688 **** --- 3685,3717 ---- } + [Test] + public void NonLazyCollections() + { + object glarchId; + + using( ISession s = sessions.OpenSession() ) + { + Glarch glarch1 = new Glarch(); + glarch1.ProxySet = new Iesi.Collections.ListSet(); + + Glarch glarch2 = new Glarch(); + glarch1.ProxySet.Add( glarch1 ); + + s.Save( glarch2 ); + glarchId = s.Save( glarch1 ); + s.Flush(); + } + + Glarch loadedGlarch; + using( ISession s = sessions.OpenSession() ) + { + loadedGlarch = (Glarch)s.Get( typeof( Glarch ), glarchId ); + Assert.IsTrue( NHibernateUtil.IsInitialized( loadedGlarch.ProxySet ) ); + } + + // ProxySet is a non-lazy collection, so this should work outside + // a session. + Assert.AreEqual( 1, loadedGlarch.ProxySet.Count ); + } } } |