From: Michael D. <mik...@us...> - 2004-08-03 04:21:23
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7178/NHibernate.Test Modified Files: ParentChildTest.cs Log Message: Implemented more tests. Index: ParentChildTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ParentChildTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParentChildTest.cs 15 Jul 2004 19:16:12 -0000 1.3 --- ParentChildTest.cs 3 Aug 2004 04:21:15 -0000 1.4 *************** *** 1,3 **** --- 1,6 ---- using System; + using System.Collections; + + using NHibernate.DomainModel; using NUnit.Framework; *************** *** 36,42 **** [Test] - [Ignore("Test not yet written")] public void CollectionQuery() { } --- 39,94 ---- [Test] public void CollectionQuery() { + ISession s = sessions.OpenSession(); + ITransaction t = s.BeginTransaction(); + + Simple s1 = new Simple(); + s1.Name = "s"; + s1.Count = 0; + Simple s2 = new Simple(); + s2.Count = 2; + Simple s3 = new Simple(); + s3.Count = 3; + s.Save( s1, (long)1 ); + s.Save( s2, (long)2 ); + s.Save( s3, (long)3 ); + Container c = new Container(); + IList l = new ArrayList(); + l.Add(s1); + l.Add(s3); + l.Add(s2); + c.OneToMany = l; + l = new ArrayList(); + l.Add(s1); + l.Add(null); + l.Add(s2); + c.ManyToMany = l; + s.Save(c); + + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX, s in class Simple where c.OneToMany[2] = s").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX, s in class Simple where c.ManyToMany[2] = s").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX, s in class Simple where s = c.OneToMany[2]").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX, s in class Simple where s = c.ManyToMany[2]").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.OneToMany[0].Name = 's'").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.ManyToMany[0].Name = 's'").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where 's' = c.OneToMany[2 - 2].Name").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where 's' = c.ManyToMany[(3+1)/4-1].Name").Count ); + if( !(dialect is Dialect.MySQLDialect) ) + { + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.ManyToMany[ c.ManyToMany.maxIndex ].Count = 2").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.ManyToMany[ maxindex(c.ManyToMany) ].Count = 2").Count ); + } + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.OneToMany[ c.ManyToMany[0].Count ].Name = 's'").Count ); + Assert.AreEqual( 1, s.Find("select c from c in class ContainerX where c.ManyToMany[ c.OneToMany[0].Count ].Name = 's'").Count ); + + s.Delete(c); + s.Delete(s1); + s.Delete(s2); + s.Delete(s3); + + t.Commit(); + s.Close(); + } |