From: Richard B. <rb...@us...> - 2005-02-11 02:53:29
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25275/InheritedClasses Modified Files: AtomsFrameworkTests.vb ManyToManyTests_v2.vb Log Message: Units tests for new many-to-many associations Index: ManyToManyTests_v2.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/ManyToManyTests_v2.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ManyToManyTests_v2.vb 10 Feb 2005 04:23:48 -0000 1.2 +++ ManyToManyTests_v2.vb 11 Feb 2005 02:53:20 -0000 1.3 @@ -141,5 +141,38 @@ Assert.AreEqual(0, c.ResultSet.ResultSet.Tables(0).Rows.Count) End Sub + <Test()> Public Sub RemoveFromCollection() + Dim gvalA, gvalB As String + Dim s As String + A = New M2MA + A.Description = "A1" + gvalA = A.GUIDValue + B = New M2MB + B.Description = "B1" + gvalB = B.GUIDValue + A.M2MBCollection.Add(B) + B.M2MACollection.Add(A) + A.Save() + pbroker.ClearCache() + A = New M2MA + A.GUIDValue = gvalA + A.Retrieve() + Assert.IsTrue(A.Persistent) + 'Being bi-directional this should result in both A/B objects having empty collections + A.M2MBCollection.Remove(0) + A.Save() + pbroker.ClearCache() + A = New M2MA + A.GUIDValue = gvalA + A.Retrieve() + B = New M2MB + B.GUIDValue = gvalB + B.Retrieve() + Assert.IsTrue(A.Persistent) + Assert.IsTrue(B.Persistent) + Assert.AreEqual(0, A.M2MBCollection.Count) + Assert.AreEqual(0, B.M2MACollection.Count) + End Sub + End Class End Namespace \ No newline at end of file Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- AtomsFrameworkTests.vb 7 Feb 2005 22:07:16 -0000 1.13 +++ AtomsFrameworkTests.vb 11 Feb 2005 02:53:20 -0000 1.14 @@ -539,6 +539,45 @@ Assert.AreEqual("bb42", CType(a1.TableBCollection.Item(1), TableB).Id) End Sub + <Test()> Public Sub CheckCacheAfterRollback5() + 'Modify but don't save an object during a transaction + Dim a As New TableA + Dim b As New TableB + Dim a1 As New TableA + a.Id = "aa5" + b.Id = "bb51" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bb52" + b.TableA = a + a.TableBCollection.Add(b) + a.Save() + Assert.AreEqual(2, a.TableBCollection.Count) + pbroker.startTransaction() + a1.Id = "aa5" + a1.Retrieve() + Assert.AreEqual(2, a1.TableBCollection.Count) + b = New TableB + b.Id = "bb53" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bb54" + b.TableA = a + a.TableBCollection.Add(b) + b = a.TableBCollection.Item(1) + Assert.AreEqual("bb52", b.Id) + a.TableBCollection.Remove(1) + Assert.AreEqual(3, a.TableBCollection.Count) + 'Now abort the transaction + pbroker.rollback() + a1 = New TableA + a1.Id = "aa5" + a1.Retrieve() 'Will get from cache + Assert.AreEqual(2, a1.TableBCollection.Count) + Assert.AreEqual("bb52", CType(a1.TableBCollection.Item(1), TableB).Id) + End Sub End Class End Namespace \ No newline at end of file |