Update of /cvsroot/jcframework/Nunit/InheritedClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv767/InheritedClasses Modified Files: AtomsFrameworkTests.vb RetrieveCriteriaTests.vb SharedTests.vb Added Files: MultiRetrieveTestClasses.vb MultiRetrieveTests.vb TableA_B.vb Log Message: Extra tests for retrieve criteria, auto save and auto delete. Index: SharedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/SharedTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SharedTests.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ SharedTests.vb 19 Oct 2004 03:30:42 -0000 1.2 @@ -18,6 +18,7 @@ retry = False Catch iox As IO.IOException 'file is in use - so we will loop around until it is released + GC.Collect() Catch ex As Exception retry = False End Try --- NEW FILE: MultiRetrieveTestClasses.vb --- Imports AToMSFramework Namespace InheritedClasses Public Class mr1 Inherits CPersistentObject Private _id As String Private _mr2_id As String Private _mr2 As mr2 Private _field1 As String Private _field2 As Integer Public Property id() As String Get Return _id End Get Set(ByVal Value As String) _id = Value SetDirtyFlag() End Set End Property Public Property mr2_id() As String Get If Not _mr2 Is Nothing Then Return _mr2.id End If Return _mr2_id End Get Set(ByVal Value As String) _mr2_id = Value SetDirtyFlag() End Set End Property Public Property mr2() As mr2 Get Return _mr2 End Get Set(ByVal Value As mr2) _mr2 = Value SetDirtyFlag() End Set End Property Public Property field1() As String Get Return _field1 End Get Set(ByVal Value As String) _field1 = Value End Set End Property Public Property field2() As Integer Get Return _field2 End Get Set(ByVal Value As Integer) _field2 = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New mr1 End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class Public Class mr2 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 End Set End Property Private _field2 As Integer Public Property field2() As Integer Get Return _field2 End Get Set(ByVal Value As Integer) _field1 = Value End Set End Property Private _mr3_id As String Private _mr3 As mr3 Public Property mr3_id() As String Get If Not _mr3 Is Nothing Then Return _mr3.id End If Return _mr3_id End Get Set(ByVal Value As String) _mr3_id = Value SetDirtyFlag() End Set End Property Public Property mr3() As mr3 Get Return _mr3 End Get Set(ByVal Value As mr3) _mr3 = Value SetDirtyFlag() End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New mr2 End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class Public Class mr3 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 End Set End Property Private _field2 As Integer Public Property field2() As Integer Get Return _field2 End Get Set(ByVal Value As Integer) _field1 = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New mr3 End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class End Namespace --- NEW FILE: TableA_B.vb --- Imports AToMSFramework Namespace InheritedClasses Public Class TableA 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 _tableBCol As New CPersistentCollection Public Property TableBCollection() As CPersistentCollection Get Return _tableBCol End Get Set(ByVal Value As CPersistentCollection) _tableBCol = Value End Set End Property Public Overrides Function getNewObject() As AToMSFramework.CPersistentObject Return New TableA End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class Public Class TableB 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 TableA End Function Public Overrides Function IsValid() As Boolean Return True End Function End Class End Namespace Index: RetrieveCriteriaTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/RetrieveCriteriaTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RetrieveCriteriaTests.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ RetrieveCriteriaTests.vb 19 Oct 2004 03:30:42 -0000 1.2 @@ -20,6 +20,7 @@ retry = False Catch iox As IO.IOException 'file is in use - so we will loop around until it is released + GC.Collect() Catch ex As Exception retry = False End Try @@ -143,8 +144,6 @@ Assert.AreEqual(emp.Name, "ab") c.nextCursor() End While - End Sub - End Class End Namespace \ No newline at end of file --- NEW FILE: MultiRetrieveTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace InheritedClasses <TestFixture()> Public Class MultiRetrieveTests Private pbroker As CPersistenceBroker Private mr1 As mr1 Private mrc As CMultiRetrieveCriteria Private c As CCursor <TestFixtureSetUp()> Public Sub Init() Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" Dim retry As Boolean = True While retry = True Try 'Remove any existing test database System.IO.File.Delete(".\db1.mdb") retry = False Catch iox As IO.IOException 'file is in use - so we will loop around until it is released GC.Collect() Catch ex As Exception retry = False End Try End While System.IO.File.Copy(".\original db1.mdb", ".\db1.mdb") pbroker = New CPersistenceBroker pbroker.init() End Sub <TestFixtureTearDown()> Public Sub Dispose() pbroker.Dispose() pbroker = Nothing End Sub <Test()> Public Sub ChainedClasses() Dim mr1 As New mr1 Dim mr2 As New mr2 Dim mr3 As New mr3 mrc = New CMultiRetrieveCriteria mrc.addObjectToJoin(mr1, Nothing, "") mrc.addObjectToJoin(mr2, mr1, "mr1tomr2") mrc.addObjectToJoin(mr3, mr2, "mr2tomr3") mrc.ReturnFullObjects = True c = mrc.perform Assert.IsTrue(c.hasElements) Assert.IsTrue(Not c.EOF) Assert.IsFalse(c.HoldsProxies) Assert.AreEqual(3, c.TotalRows) End Sub <Test()> Public Sub ChainedClassesWithOrderBy() Dim mr1 As New mr1 Dim mr2 As New mr2 Dim mr3 As New mr3 mrc = New CMultiRetrieveCriteria mrc.addObjectToJoin(mr1, Nothing, "") mrc.addObjectToJoin(mr2, mr1, "mr1tomr2") mrc.addObjectToJoin(mr3, mr2, "mr2tomr3") mrc.addOrderAttribute("mr3.field1") mrc.ReturnFullObjects = True c = mrc.perform Assert.IsTrue(c.hasElements) Assert.IsTrue(Not c.EOF) Assert.IsFalse(c.HoldsProxies) Assert.AreEqual(3, c.TotalRows) End Sub End Class End Namespace Index: AtomsFrameworkTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/InheritedClasses/AtomsFrameworkTests.vb,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- AtomsFrameworkTests.vb 19 Oct 2004 00:13:38 -0000 1.1 +++ AtomsFrameworkTests.vb 19 Oct 2004 03:30:42 -0000 1.2 @@ -18,6 +18,7 @@ System.IO.File.Delete(".\db1.mdb") retry = False Catch iox As IO.IOException + GC.Collect() 'file is in use - so we will loop around until it is released Catch ex As Exception retry = False @@ -183,5 +184,39 @@ emp.Find() Assert.IsTrue(emp.Persistent) End Sub + + <Test()> Public Sub AutoDelete() + Dim a As New TableA + Dim b As New TableB + Dim cc As CCursor + a.Id = "a1" + a.Retrieve() + Assert.IsTrue(a.Persistent) + Assert.AreEqual(2, a.TableBCollection.Count) + a.Delete() + Dim rc As New CRetrieveCriteria + rc.ClassMap = b.getClassMap + rc.WhereCondition.addSelectEqualTo("AId", "a1") + cc = rc.perform() + Assert.AreEqual(0, cc.TotalRows) + Assert.IsFalse(cc.hasElements) + End Sub + + <Test()> Public Sub AutoSave() + Dim a As New TableA + Dim b As New TableB + Dim cc As CCursor + a.Id = "a3" + b.Id = "b33" + b.TableA = a + a.TableBCollection.Add(b) + a.Save() + Dim rc As New CRetrieveCriteria + rc.ClassMap = b.getClassMap + rc.WhereCondition.addSelectEqualTo("AId", "a3") + cc = rc.perform() + Assert.AreEqual(1, cc.TotalRows) + Assert.IsTrue(cc.hasElements) + End Sub End Class End Namespace \ No newline at end of file |