From: Richard B. <rb...@us...> - 2004-10-18 01:38:48
|
Update of /cvsroot/jcframework/Nunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23134 Modified Files: AtomsFramework.xml Nunit_AtomsFramework.vbproj Added Files: EmployeeInterfaceTests.vb IEmployee.vb Log Message: Tests for interface persistence Index: Nunit_AtomsFramework.vbproj =================================================================== RCS file: /cvsroot/jcframework/Nunit/Nunit_AtomsFramework.vbproj,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Nunit_AtomsFramework.vbproj 18 Oct 2004 00:07:09 -0000 1.6 +++ Nunit_AtomsFramework.vbproj 18 Oct 2004 01:38:39 -0000 1.7 @@ -140,6 +140,16 @@ BuildAction = "Compile" /> <File + RelPath = "EmployeeInterfaceTests.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IEmployee.vb" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NonInheritedRetreiveCriteria.vb" SubType = "Code" BuildAction = "Compile" --- NEW FILE: EmployeeInterfaceTests.vb --- Imports AToMSFramework Imports NUnit.Framework <TestFixture()> Public Class EmployeeInterfaceTests Private pbroker As CPersistenceBroker Private emp As IEmployee <TestFixtureSetUp()> Public Sub Init() Environment.CurrentDirectory = "C:\Projects\MMM\Nunit_AtomsFramework" Try 'Remove any existing test database System.IO.File.Delete(".\db1.mdb") Catch ex As Exception End Try 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 <SetUp()> Public Sub TestInit() emp = New EmployeeClass End Sub <Test()> Public Sub LoadEmployee_a() emp.Name = "a" pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.AreEqual(emp.Workers.Count, 0) Assert.IsTrue(Not emp.ReportsTo Is Nothing) Assert.AreEqual(emp.ReportsTo.Name, "c") Dim emp2 As IEmployee emp2 = emp.ReportsTo.Workers(0) Assert.AreEqual(emp2.Name, emp.Name) Assert.AreEqual(emp2.OIDValue, emp.OIDValue) Assert.AreSame(emp2, emp) End Sub <Test()> Public Sub LoadEmployee_ac() emp.Name = "ac" pbroker.FindObject(emp) Assert.IsTrue(pbroker.getInjectedObject(emp).Persistent) Assert.AreEqual(emp.Workers.Count, 3) emp = emp.Workers.Item(1) Assert.AreEqual(emp.Name, "aa") Assert.AreEqual(emp.ReportsTo.Name, "ac") End Sub <Test()> Public Sub CheckSchemaBasedProperties() emp.Name = "ac" pbroker.FindObject(emp) Assert.AreEqual(50, pbroker.getInjectedObject(emp).getFieldLengthByName("Name")) Assert.IsTrue(pbroker.getInjectedObject(emp).getFieldTypeByName("Name") Is GetType([String])) End Sub End Class --- NEW FILE: IEmployee.vb --- Public Interface IEmployee Property OIDValue() As String Property Name() As String Property ReportsTo() As IEmployee Property ReportsToOID() As String Property Workers() As ArrayList Property Team() As CTeam Property TeamOID() As String End Interface Public Class EmployeeClass Implements IEmployee Private m_name As String Private m_parentoid As String Private m_parent As IEmployee Private m_children As ArrayList Private m_team As CTeam Private m_teamoid As String Private m_oid As AToMSFramework.COID Public Property OIDValue() As String Implements IEmployee.OIDValue Get Dim oidfactory As AToMSFramework.COIDFactory If m_oid Is Nothing Then oidfactory = AToMSFramework.modOIDFactorySingleton.getOIDFactoryInstance() m_oid = oidfactory.newOID End If OIDValue = m_oid.OID End Get Set(ByVal value As String) If m_oid Is Nothing Then m_oid = New AToMSFramework.COID End If m_oid.OID = value End Set End Property Public Property Name() As String Implements IEmployee.Name Get Return m_name End Get Set(ByVal Value As String) m_name = Value End Set End Property Public Property ReportsTo() As IEmployee Implements IEmployee.ReportsTo Get Return m_parent End Get Set(ByVal Value As IEmployee) If Not Value Is Nothing Then m_parent = Value m_parentoid = Value.OIDValue End If End Set End Property Public Property ReportsToOID() As String Implements IEmployee.ReportsToOID Get If m_parent Is Nothing Then Return m_parentoid Else Return (m_parent.OIDValue) End If End Get Set(ByVal Value As String) m_parentoid = Value End Set End Property Public Property Workers() As ArrayList Implements IEmployee.Workers Get Return m_children End Get Set(ByVal Value As ArrayList) m_children = Value End Set End Property Public Property Team() As CTeam Implements IEmployee.Team Get Return m_team End Get Set(ByVal Value As CTeam) If Not Value Is Nothing Then m_team = Value m_teamoid = Value.OIDValue End If End Set End Property Public Property TeamOID() As String Implements IEmployee.TeamOID Get If m_team Is Nothing Then Return m_teamoid Else Return (m_team.OIDValue) End If End Get Set(ByVal Value As String) m_teamoid = Value End Set End Property Public Sub New() MyBase.New() m_children = New ArrayList End Sub End Class Public Class IEmployeeFactory Implements AToMSFramework.IClassFactory Public Function CreateObject() As Object Implements AToMSFramework.IClassFactory.CreateObject Return New EmployeeClass End Function End Class Index: AtomsFramework.xml =================================================================== RCS file: /cvsroot/jcframework/Nunit/AtomsFramework.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- AtomsFramework.xml 15 Oct 2004 06:47:04 -0000 1.4 +++ AtomsFramework.xml 18 Oct 2004 01:38:39 -0000 1.5 @@ -71,4 +71,24 @@ <entry fromAttribute="OIDValue" toAttribute="TeamOID"/> </association> +<class name="IEmployee" table="employee" database="MSA" factory="IEmployeeFactory"> + <attribute name="OIDValue" column="oid" key="primary"/> + <attribute name="Name" column="name" find="true"/> + <attribute name="ReportsToOID" column="parentoid" /> + <attribute name="TeamOID" column="teamoid" /> + <attribute name="Team" /> + <attribute name="ReportsTo" /> + <attribute name="Workers" /> +</class> + + <association fromClass="IEmployee" toClass="IEmployee" target="ReportsTo" cardinality="OneToOne" + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> + <entry fromAttribute="ReportsToOID" toAttribute="OIDValue"/> + </association> + + <association fromClass="IEmployee" toClass="IEmployee" target="Workers" cardinality="OneToMany" + retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="false" inverse="false"> + <entry fromAttribute="OIDValue" toAttribute="ReportsToOID"/> + </association> + </map> \ No newline at end of file |