From: Sergey K. <jus...@us...> - 2005-03-26 13:25:16
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1460/src/NHibernate.Test Modified Files: ABCProxyTest.cs FooBarTest.cs Log Message: Ported property-ref attribute implementation from Hibernate 2.1 Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** FooBarTest.cs 14 Mar 2005 18:56:13 -0000 1.86 --- FooBarTest.cs 26 Mar 2005 13:24:35 -0000 1.87 *************** *** 17,39 **** { ExportSchema(new string[] { ! "FooBar.hbm.xml", ! "Baz.hbm.xml", ! "Qux.hbm.xml", ! "Glarch.hbm.xml", ! "Fum.hbm.xml", ! "Fumm.hbm.xml", ! "Fo.hbm.xml", ! "One.hbm.xml", ! "Many.hbm.xml", ! "Immutable.hbm.xml" , ! "Fee.hbm.xml", ! "Vetoer.hbm.xml", ! "Holder.hbm.xml", ! "Location.hbm.xml", ! "Stuff.hbm.xml", ! "Container.hbm.xml", ! "Simple.hbm.xml", ! "XY.hbm.xml" ! }, true); } --- 17,39 ---- { ExportSchema(new string[] { ! "FooBar.hbm.xml", ! "Baz.hbm.xml", ! "Qux.hbm.xml", ! "Glarch.hbm.xml", ! "Fum.hbm.xml", ! "Fumm.hbm.xml", ! "Fo.hbm.xml", ! "One.hbm.xml", ! "Many.hbm.xml", ! "Immutable.hbm.xml" , ! "Fee.hbm.xml", ! "Vetoer.hbm.xml", ! "Holder.hbm.xml", ! "Location.hbm.xml", ! "Stuff.hbm.xml", ! "Container.hbm.xml", ! "Simple.hbm.xml", ! "XY.hbm.xml" ! }, true); } *************** *** 816,820 **** [Test] ! //[Ignore("TimeZone Portions commented out - http://jira.nhibernate.org:8080/browse/NH-88")] public void AssociationId() { --- 816,820 ---- [Test] ! //[Ignore("TimeZone Portions commented out - http://jira.nhibernate.org:8080/browse/NH-88")] public void AssociationId() { *************** *** 968,972 **** { ISession s = sessions.OpenSession(); ! // ITransaction t = s.BeginTransaction(); Foo[] foos = new Foo[] { null, new Foo() }; s.Save(foos[1]); --- 968,972 ---- { ISession s = sessions.OpenSession(); ! // ITransaction t = s.BeginTransaction(); Foo[] foos = new Foo[] { null, new Foo() }; s.Save(foos[1]); *************** *** 1071,1075 **** s.Delete(baz2); s.Delete(foos[1]); ! // t.Commit(); s.Close(); --- 1071,1075 ---- s.Delete(baz2); s.Delete(foos[1]); ! // t.Commit(); s.Close(); *************** *** 1202,1207 **** //if( !(dialect is Dialect.SAPDBDialect) ) //{ ! list = s.Find("select distinct foo from baz in class NHibernate.DomainModel.Baz, foo in baz.FooArray.elements"); ! Assert.AreEqual( 2, list.Count, "collection.elements find" ); //} --- 1202,1207 ---- //if( !(dialect is Dialect.SAPDBDialect) ) //{ ! list = s.Find("select distinct foo from baz in class NHibernate.DomainModel.Baz, foo in baz.FooArray.elements"); ! Assert.AreEqual( 2, list.Count, "collection.elements find" ); //} *************** *** 1777,1781 **** list = s.Find( "select foo, bar from Foo foo left outer join foo.TheFoo bar where foo = ?", foo, ! NHibernateUtil.Entity( typeof(Foo) ) ); --- 1777,1781 ---- list = s.Find( "select foo, bar from Foo foo left outer join foo.TheFoo bar where foo = ?", foo, ! NHibernateUtil.Entity( typeof(Foo) ) ); *************** *** 1786,1793 **** s.Find( "select foo.TheFoo.TheFoo.TheFoo.String from foo in class Foo where foo.TheFoo.TheFoo = 'bar'" ); s.Find( "select foo.TheFoo.TheFoo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo.String = 'bar'" ); ! // if( !( dialect is Dialect.HSQLDialect ) ) ! // { ! s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo = foo.TheFoo.TheFoo" ); ! // } s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo = 'bar' and foo.TheFoo.TheFoo.TheFoo = 'baz'" ); s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo.String = 'a' and foo.TheFoo.String = 'b'" ); --- 1786,1793 ---- s.Find( "select foo.TheFoo.TheFoo.TheFoo.String from foo in class Foo where foo.TheFoo.TheFoo = 'bar'" ); s.Find( "select foo.TheFoo.TheFoo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo.String = 'bar'" ); ! // if( !( dialect is Dialect.HSQLDialect ) ) ! // { ! s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo = foo.TheFoo.TheFoo" ); ! // } s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo = 'bar' and foo.TheFoo.TheFoo.TheFoo = 'baz'" ); s.Find( "select foo.String from foo in class Foo where foo.TheFoo.TheFoo.TheFoo.String = 'a' and foo.TheFoo.String = 'b'" ); *************** *** 2126,2131 **** s = sessions.OpenSession(); Assert.AreEqual( 10, ! s.Delete( "from Simple" ), ! "delete by query" ); s.Flush(); --- 2126,2131 ---- s = sessions.OpenSession(); Assert.AreEqual( 10, ! s.Delete( "from Simple" ), ! "delete by query" ); s.Flush(); *************** *** 3256,3260 **** e = s.Enumerable("from baz in class NHibernate.DomainModel.Baz where ? in baz.FooArray.elements", foo, ! NHibernateUtil.Entity( typeof(Foo) ) ).GetEnumerator(); Assert.IsFalse( e.MoveNext() ); --- 3256,3260 ---- e = s.Enumerable("from baz in class NHibernate.DomainModel.Baz where ? in baz.FooArray.elements", foo, ! NHibernateUtil.Entity( typeof(Foo) ) ).GetEnumerator(); Assert.IsFalse( e.MoveNext() ); *************** *** 3362,3367 **** bool proxyBoolean = ( (FooProxy)s.Load( typeof(Foo), id )).Boolean; } ! // this won't work until Proxies are implemented because now it throws an ! // ObjectNotFoundException catch(LazyInitializationException lie) { --- 3362,3367 ---- bool proxyBoolean = ( (FooProxy)s.Load( typeof(Foo), id )).Boolean; } ! // this won't work until Proxies are implemented because now it throws an ! // ObjectNotFoundException catch(LazyInitializationException lie) { *************** *** 3717,3720 **** --- 3717,3757 ---- Assert.AreEqual( 1, loadedGlarch.ProxySet.Count ); } + + [Test] + public void PropertyRef() + { + object qid; + object hid; + + using( ISession s = sessions.OpenSession() ) + { + Holder h = new Holder(); + h.Name = "foo"; + Holder h2 = new Holder(); + h2.Name = "bar"; + h.OtherHolder = h2; + hid = s.Save(h); + + Qux q = new Qux(); + q.Holder = h2; + qid = s.Save( q ); + s.Flush(); + } + + using( ISession s = sessions.OpenSession() ) + { + Holder h = (Holder) s.Load( typeof(Holder), hid ); + Assert.AreEqual( h.Name, "foo" ); + Assert.AreEqual( h.OtherHolder.Name, "bar" ); + object[] res = (object[]) s.Find("from Holder h join h.OtherHolder oh where h.OtherHolder.Name = 'bar'")[0]; + Assert.AreSame( h, res[0] ); + + Qux q = (Qux) s.Get( typeof(Qux), qid ); + Assert.AreSame( q.Holder, h.OtherHolder ); + s.Delete( h ); + s.Delete( q ); + s.Flush(); + } + } } } Index: ABCProxyTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ABCProxyTest.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ABCProxyTest.cs 17 Jan 2005 03:40:51 -0000 1.12 --- ABCProxyTest.cs 26 Mar 2005 13:24:35 -0000 1.13 *************** *** 43,47 **** [Test] ! //[Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void Subclassing() { --- 43,47 ---- [Test] ! //[Ignore("Proxies Required - http://jira.nhibernate.org:8080/browse/NH-41")] public void Subclassing() { *************** *** 190,193 **** --- 190,261 ---- t.Commit(); } + + [Test] + public void OneToOne() + { + A a = new A(); + E d1 = new E(); + C1 c = new C1(); + E d2 = new E(); + a.Forward = d1; + d1.Reverse = a; + c.Forward = d2; + d2.Reverse = c; + + object aid; + object d2id; + + using( ISession s = sessions.OpenSession() ) + using( ITransaction t = s.BeginTransaction() ) + { + aid = s.Save(a); + d2id = s.Save(d2); + t.Commit(); + } + + using( ISession s = sessions.OpenSession() ) + using( ITransaction t = s.BeginTransaction() ) + { + IList l = s.Find( "from E e, A a where e.Reverse = a.Forward and a = ?", a, NHibernateUtil.Entity (typeof(A)) ); + Assert.AreEqual( 1, l.Count ); + l = s.Find( "from E e join fetch e.Reverse" ); + Assert.AreEqual( 2, l.Count ); + t.Commit(); + } + + using( ISession s = sessions.OpenSession() ) + using( ITransaction t = s.BeginTransaction() ) + { + IList l = s.Find( "from E e" ); + Assert.AreEqual( 2, l.Count ); + E e = (E) l[ 0 ]; + Assert.AreSame( e, e.Reverse.Forward ); + e = (E) l[ 1 ]; + Assert.AreSame( e, e.Reverse.Forward ); + t.Commit(); + } + + using( ISession s = sessions.OpenSession() ) + using( ITransaction t = s.BeginTransaction() ) + { + a = (A) s.Load( typeof(A), aid ); + d2 = (E) s.Load( typeof(E), d2id ); + Assert.AreSame( a, a.Forward.Reverse ); + Assert.AreSame( d2, d2.Reverse.Forward ); + s.Delete( a ); + s.Delete( a.Forward ); + s.Delete( d2 ); + s.Delete( d2.Reverse ); + t.Commit(); + } + + using( ISession s = sessions.OpenSession() ) + using( ITransaction t = s.BeginTransaction() ) + { + IList l = s.Find( "from E e" ); + Assert.AreEqual( 0, l.Count ); + t.Commit(); + } + } } } |