From: Richard B. <rb...@us...> - 2005-02-10 04:23:58
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv837/InheritedClasses Modified Files: ManyToManyTests_v2.vb Log Message: Unit test for many-to-many deletion Index: ManyToManyTests_v2.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/ManyToManyTests_v2.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ManyToManyTests_v2.vb 9 Feb 2005 06:20:50 -0000 1.1 +++ ManyToManyTests_v2.vb 10 Feb 2005 04:23:48 -0000 1.2 @@ -74,5 +74,72 @@ Assert.AreEqual(2, B.M2MACollection.Count) End Sub + <Test()> Public Sub SaveThenDelete() + Dim gval As String + Dim x As Integer, y As Integer + A = New M2MA + A.Description = "A1" + gval = A.GUIDValue + B = New M2MB + B.Description = "B1" + A.M2MBCollection.Add(B) + B.M2MACollection.Add(A) + Dim B2 As M2MB = New M2MB + B2.Description = "B2" + A.M2MBCollection.Add(B2) + Dim A2 As M2MA = New M2MA + A2.Description = "A2" + B2.M2MACollection.Add(A2) + A.Save() + pbroker.ClearCache() + A = New M2MA + A.GUIDValue = gval + A.Retrieve() + Assert.AreEqual(2, A.M2MBCollection.Count) + 'Order of guids can affect order of the collection + If A.M2MBCollection.Item(0).M2MACollection.Count = 1 Then + x = 0 + y = 1 + Else + x = 1 + y = 0 + End If + B = A.M2MBCollection.Item(x) + Assert.IsNotNull(B) + Assert.AreEqual("B1", B.Description) + Assert.AreEqual(1, B.M2MACollection.Count) + Assert.IsTrue(A.Equals(B.M2MACollection.Item(0))) + B = A.M2MBCollection.Item(y) + Assert.IsNotNull(B) + Assert.AreEqual("B2", B.Description) + Assert.AreEqual(2, B.M2MACollection.Count) + 'Now delete B2 - because of autodelete, allobjects should be delete + B.Delete() + A = New M2MA + A.GUIDValue = gval + A.Retrieve() + Assert.IsFalse(A.Persistent) + End Sub + + <Test()> Public Sub SaveThenChangeKeyValues() + 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() + A.GUIDValue = Guid.NewGuid.ToString("N") + A.SetDirtyFlag() + A.Save() + s = "select * from ManyToManyAB where AGuidValue = """ & gvalA & """ and BGuidValue = """ & gvalB & """" + Dim c As CCursor = pbroker.ProcessPureSQL(s, A.getClassMap.RelationalDatabase.getConnection(Nothing)) + Assert.AreEqual(0, c.ResultSet.ResultSet.Tables(0).Rows.Count) + End Sub + End Class End Namespace \ No newline at end of file |