'Interface Command PublicSubExecute(): End Sub 'TestCommand Implements VB6DPFrameWork.Command Public Count AsInteger PrivateSub Command_Execute() Count =1 End Sub 'CommandWrapper Private mSelf As TestCommand Private mInterface As VB6DPFrameWork.Command PublicSub Dispose() Set mSelf =Nothing Set mInterface =Nothing End Sub PublicSub Instance() If mInterface IsNothingThen Set mInterface =New TestCommand Set mSelf = mInterface EndIf End Sub PublicFunction Interface() As VB6DPFrameWork.Command Instance Set Interface = mInterface End Function PublicFunction Self() As TestCommand Instance Set Self = mSelf End Function 'TestCase PublicSub Test_Wrapper(oTestResult As TestResult) With oTestResult Dim w AsNew CommandWrapper w.Interface.Execute .AssertEqualsLong w.Self.Count, 1 Set w =Nothing EndWith End Sub
TestCommand继承了Command接口,如果采用 dim t as command的方式,将不能访问Count属性。 如果采用 dim t as testcommand方式,将不能访问Execute方法。