From: Michael D. <mik...@us...> - 2004-09-22 04:47:57
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20845/NHibernate.Test Modified Files: ParentChildTest.cs Log Message: Test Case to catch new bug found with Bags. Index: ParentChildTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ParentChildTest.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ParentChildTest.cs 31 Aug 2004 20:37:28 -0000 1.8 --- ParentChildTest.cs 22 Sep 2004 04:47:47 -0000 1.9 *************** *** 477,480 **** --- 477,497 ---- s.Close(); + // new test code in here to catch when a lazy bag has an addition then + // is flushed and then an operation that causes it to read from the db + // occurs - this used to cause the element in Add(element) to be in there + // twice and throw off the count by 1 (or by however many additions were + // made before the flush + s = sessions.OpenSession(); + c = (Container)s.Find("from c in class ContainerX")[0]; + Contained c5 = new Contained(); + c.LazyBag.Add( c5 ); + c5.LazyBag.Add( c ); + + // this causes the additions to be written to the db - now verify + // the additions list was cleared and the count returns correctly + s.Flush(); + Assert.AreEqual( 4, c.LazyBag.Count, "correct additions clearing after flush" ); + s.Close(); + s = sessions.OpenSession(); t = s.BeginTransaction(); *************** *** 488,492 **** Assert.AreEqual( 3, j); ! Assert.AreEqual( 3, c.LazyBag.Count ); s.Delete(c); c.Bag.Remove(c2); --- 505,512 ---- Assert.AreEqual( 3, j); ! ! // this used to be 3 - but since I added an item in the test above for flush ! // I increased it to 4 ! Assert.AreEqual( 4, c.LazyBag.Count ); s.Delete(c); c.Bag.Remove(c2); *************** *** 500,503 **** --- 520,524 ---- Assert.AreEqual( 2, j ); + s.Delete( s.Load( typeof(Contained), c5.Id ) ); s.Delete( s.Load( typeof(Contained), c4.Id ) ); s.Delete( s.Load( typeof(Contained), c3.Id ) ); |