Video example:
See the full example in the demo application LevelUnits.dpr
Example of creating a module testing test from Delphi delivery.
1. Registration in multiple modules (System.pas & Math) in the same class.
unit SysDelphi; interface uses Math, TestMeType,TestMeLevelType ; type TTest_DelphiBorland=class // TestMeType System.pas class Procedure System_RM;// _RegisterMethod class Function System_TM( IMethod:IRunMethodParam):TTestResultParam;//_TestMethods // Test Math.pas class Procedure Math_RM; class Function Math_TM( IMethod:IRunMethodParam):TTestResultParam; end; implementation type TTM_System = (tsPointSize); TTM_Math = (tmCos,tmMin); var L_piUnit,L_piSystem,L_piMath :TPIndexValue; class procedure TTest_DelphiBorland.System_RM; begin if not GetTestMe.bIsTestCode then Exit; with GetTestMe.ITestCode do begin if not ISetDefaultIndUnitClass(L_piUnit,L_piSystem) then exit; // Set position IRegisterMethod(tsPointSize ,'PointSize' ,'Test Point Size',pAddOneEmptyParam);// Test methods end; //with end; class function TTest_DelphiBorland.System_TM( IMethod: IRunMethodParam): TTestResultParam; begin case TTM_System(IMethod.IGetNumParamUser) of tsPointSize: begin if SizeOf(pointer)={$IFDEF WIN32} 4 {$ELSE} 8 {$ENDIF} then result:=trOk else result:=trError; end; end; // case end; class procedure TTest_DelphiBorland.Math_RM; begin if not GetTestMe.bIsTestCode then Exit; with GetTestMe.ITestCode do begin if not ISetDefaultIndUnitClass(L_piUnit,L_piMath) then exit; // Set position IRegisterMethod(tmCos ,'tmCos' ,'Test function COS');// Test methods IRegisterMethodParams([0],[1],'Cos(0)=1'); // True result IRegisterMethod(tmMin ,'tmMin' ,'Test function Min');// Test methods IRegisterMethodParams([1,-1],[-1],'Min(1,-1)= -1'); // True result IRegisterMethodParams([-2,-5],[-5],'Min(-2,-5)= -5'); // True result end; //withend; end; class function TTest_DelphiBorland.Math_TM( IMethod: IRunMethodParam): TTestResultParam; begin case TTM_Math(IMethod.IGetNumParamUser) of tmCos: begin if (Cos(IMethod.IGetArrParam(0).AsInteger) = IMethod.IGetArrResultForTestMethod(0).AsInteger) then result:=trOk else result:=trError; end; tmMin: begin if (Min(IMethod.IGetArrParam(0).AsInteger,IMethod.IGetArrParam(1).AsInteger) = IMethod.IGetArrResultForTestMethod(0).AsInteger) then result:=trOk else result:=trError; end; end; // case end; initialization if GetTestMe.bIsTestCode then begin with GetTestMe.ITestCode do begin L_piUnit:=IRegisterUnit(ltSystem_Delphi,'SysDelphi.pas','Test Delphi units'); L_piSystem := IRegisterClass(TTest_DelphiBorland.System_RM,TTest_DelphiBorland.System_TM,'Systems.pas','Test Delphi Systems.pas'); L_piMath := IRegisterClass(TTest_DelphiBorland.Math_RM,TTest_DelphiBorland.Math_TM,'Math.pas','Test Delphi Math.pas'); end; end; end.