From: Richard B. <rb...@us...> - 2004-10-31 23:08:47
|
Update of /cvsroot/jcframework/Nunit/StandardClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11585/StandardClasses Modified Files: NonInheritedTests.vb Added Files: LazyEmployee.vb Log Message: Tests for lazy loading of objects in associations. Index: NonInheritedTests.vb =================================================================== RCS file: /cvsroot/jcframework/Nunit/StandardClasses/NonInheritedTests.vb,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- NonInheritedTests.vb 25 Oct 2004 07:14:15 -0000 1.3 +++ NonInheritedTests.vb 31 Oct 2004 23:08:36 -0000 1.4 @@ -211,5 +211,14 @@ Assert.AreEqual("slave", emp2.Name) End Sub + <Test()> Public Sub LazyLoadEmployees() + Dim emp1 As New LazyEmployee + emp1.Name = "aa" + pbroker.FindObject(emp1) + Assert.AreEqual("aa", emp1.Name) + Assert.AreEqual("ac", emp1.ReportsTo.Name) + Assert.AreEqual(emp1.ReportsToName, emp1.ReportsTo.Name) + Assert.AreEqual(0, emp1.ReportsTo.Workers.Count) + End Sub End Class End Namespace \ No newline at end of file --- NEW FILE: LazyEmployee.vb --- Namespace StandardClasses Public Class LazyEmployee Private m_name As String Private m_parentname As String Private m_parent As LazyEmployee Private m_children As ArrayList Private m_teamname As String Public Property Name() As String Get Return m_name End Get Set(ByVal Value As String) m_name = Value End Set End Property Public Property ReportsTo() As LazyEmployee Get Return m_parent End Get Set(ByVal Value As LazyEmployee) If Not Value Is Nothing Then m_parent = Value m_parentname = Value.Name End If End Set End Property Public Property ReportsToName() As String Get If m_parent Is Nothing Then Return m_parentname Else Return (m_parent.Name) End If End Get Set(ByVal Value As String) m_parentname = Value End Set End Property Public Property Workers() As ArrayList Get Return m_children End Get Set(ByVal Value As ArrayList) m_children = Value End Set End Property Public Sub New() MyBase.New() m_children = New ArrayList End Sub End Class End Namespace |