From: Richard B. <rb...@us...> - 2004-10-19 00:13:48
|
Update of /cvsroot/jcframework/Nunit/Interfaces In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19366/Interfaces Added Files: EmployeeInterfaceTests.vb IEmployee.vb Log Message: Rearrange unit test structure (extra namespaces and folders) --- NEW FILE: EmployeeInterfaceTests.vb --- Imports AToMSFramework Imports NUnit.Framework Namespace Interfaces <TestFixture()> Public Class EmployeeInterfaceTests Private pbroker As CPersistenceBroker Private emp As IEmployee <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 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 <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 End Namespace --- NEW FILE: IEmployee.vb --- Namespace Interfaces 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 InheritedClasses.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 InheritedClasses.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 InheritedClasses.CTeam Implements IEmployee.Team Get Return m_team End Get Set(ByVal Value As InheritedClasses.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 End Namespace |