From: Richard B. <rb...@us...> - 2004-10-21 23:36:57
|
Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5970/InheritedClasses Modified Files: AtomsFrameworkTests.vb TableA_B.vb Log Message: Extra tests for duplicates in collections, and deleting non-inherited objects Index: TableA_B.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/TableA_B.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TableA_B.vb 19 Oct 2004 03:30:42 -0000 1.1 +++ TableA_B.vb 21 Oct 2004 23:36:46 -0000 1.2 @@ -36,6 +36,16 @@ End Set End Property + Private _tableCCol As New CPersistentCollection + Public Property TableCCollection() As CPersistentCollection + Get + Return _tableCCol + End Get + Set(ByVal Value As CPersistentCollection) + _tableCCol = Value + End Set + End Property + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New TableA End Function @@ -95,7 +105,65 @@ End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject - Return New TableA + Return New TableB + End Function + + Public Overrides Function IsValid() As Boolean + Return True + End Function + End Class + + Public Class TableC + Inherits CPersistentObject + + Private _id As String + Public Property Id() As String + Get + Return _id + End Get + Set(ByVal Value As String) + _id = Value + SetDirtyFlag() + End Set + End Property + + Private _field1 As String + Public Property field1() As String + Get + Return _field1 + End Get + Set(ByVal Value As String) + _field1 = Value + SetDirtyFlag() + End Set + End Property + + Private _a As TableA + Private _a_id As String + Public Property TableA() As TableA + Get + Return _a + End Get + Set(ByVal Value As TableA) + _a = Value + SetDirtyFlag() + End Set + End Property + + Public Property AId() As String + Get + If _a Is Nothing Then + Return _a_id + End If + Return _a.Id + End Get + Set(ByVal Value As String) + _a_id = Value + End Set + End Property + + Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject + Return New TableC End Function Public Overrides Function IsValid() As Boolean Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AtomsFrameworkTests.vb 19 Oct 2004 03:30:42 -0000 1.2 +++ AtomsFrameworkTests.vb 21 Oct 2004 23:36:46 -0000 1.3 @@ -115,6 +115,14 @@ emp.Name = "DeleteMe1" emp.Find() Assert.IsFalse(emp.Persistent) + emp = New CEmployee + emp.Name = "DeleteMe2" + emp.Find() + Assert.IsFalse(emp.Persistent) + emp = New CEmployee + emp.Name = "DeleteMe3" + emp.Find() + Assert.IsFalse(emp.Persistent) End Sub <Test()> Public Sub LoadEmployee_ac() @@ -218,5 +226,45 @@ Assert.AreEqual(1, cc.TotalRows) Assert.IsTrue(cc.hasElements) End Sub + + <Test()> Public Sub CheckForDuplicates() + 'Tests is multiple one-to-many associations in an object causes + 'duplicates in a collection. + Dim a As New TableA + Dim b As New TableB + Dim c As New TableC + a.Id = "aa" + b.Id = "bb1" + b.TableA = a + a.TableBCollection.Add(b) + b = New TableB + b.Id = "bb2" + b.TableA = a + a.TableBCollection.Add(b) + c = New TableC + c.Id = "cc1" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc2" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc3" + c.TableA = a + a.TableCCollection.Add(c) + c = New TableC + c.Id = "cc4" + c.TableA = a + a.TableCCollection.Add(c) + a.Save() + pbroker.ClearCache() + a = New TableA + a.Id = "aa" + a.Retrieve() + Assert.AreEqual(2, a.TableBCollection.Count) + Assert.AreEqual(4, a.TableCCollection.Count) + End Sub + End Class End Namespace \ No newline at end of file |