*** TESTE CRLF = CHR(13) + CHR(10) CTAB = CHR(9) gcTestMessage = "" gcHost = "jcsserver" gcUser = "mariusm_auto" gcPassword = "123" gnHandle = 0 *!* FACTURA lnCodF = 1105748 lnLunaF = 8 lnAnF = 2006 lnIdFactF = 5006097 *!* INCASARE lnCodI = 1105749 lnLunaI = 8 lnAnI = 2006 lnIdFactI = 5006097 lnIdFactPI = 5006097 SET PROCEDURE TO D:\ROA_RB\ROACONT\COMUN\programe\odocumente ADDITIVE SET PROCEDURE TO D:\ROA_RB\ROACONT\COMUN\programe\oproceduri_comune.prg ADDITIVE goExecutor = CREATEOBJECT("oExecutor") goConn = CREATEOBJECT("oConn") loMyTests = CREATEOBJECT("MyTests") loMyTests.teste() DEFINE CLASS MyTests AS CUSTOM ***================================================== PROCEDURE teste LOCAL lcFile, lnRows, lcProcedure,i lcFile = FORCEEXT(SYS(16),'prg') IF ATC('PROCEDURE', lcFile) > 0 lcFile = SUBSTR(lcFile, AT(':', lcFile)-1) ENDIF IF !FILE(lcFile) this.appendMessage("Error", 'Nu exista fisierul ' + lcFile) MESSAGEBOX(gcTestMessage) RETURN ENDIF lnRows = APROCINFO(laproc,lcFile) lcProcedure = "" gnHandle = this.initializare(gcHost, gcUser, gcPassword) lcTestFile = SYS(16) IF gnHandle > 0 FOR i = 1 TO lnRows lcProcedure = laProc[i,1] IF AT('.', lcProcedure) > 0 lcProcedure = SUBSTR(lcProcedure, AT('.', lcProcedure) + 1) ENDIF IF LOWER(laproc[i,3]) <> 'procedure' OR LEFT(LOWER(lcProcedure), 5) <> 'test_' LOOP ENDIF lnSucces = THIS.&lcProcedure.() ENDFOR *!* lnSucces = this.test_referintedocumentenota() *!* lnSucces = this.test_referintedocument() ENDIF lnSucces = this.curatare(gnHandle) MESSAGEBOX(gcTestMessage) ENDPROC && teste ***================================================== FUNCTION initializare LPARAMETERS tcHost, tcUser, tcPassword LOCAL lnHandle lnHandle = goConn.connect(tcHost, tcUser, tcPassword) IF lnHandle <= 0 this.appendMessage("Error","Nu s-a realizat conexiunea") ELSE this.appendMessage("Succes","S-a realizat conexiunea") ENDIF RETURN lnHandle ENDFUNC && initializare FUNCTION Error(nError,cMethod,nLine) LOCAL lcError lcError = MESSAGE() + ';' + TRANSFORM(nError) + ';' + cMethod + ';' + ';' + TRANSFORM(nLine) DEBUG SUSPEND this.appendMessage("Error",lcError) ENDFUNC && Error ***================================================== FUNCTION curatare LPARAMETERS tnHandle LOCAL lnSucces lnSucces = 1 IF tnHandle > 0 lnSucces = SQLDISCONNECT(tnHandle) ENDIF IF lnSucces <= 0 this.appendMessage("Error","Nu s-a inchis conexiunea") ELSE this.appendMessage("Succes","S-a inchis conexiunea") ENDIF RETURN lnSucces ENDFUNC && curatare ***================================================== PROCEDURE Verifica LPARAMETERS tuValue1, tuValue2, tcTest, tcMessage IF tuValue1 <> tuValue2 this.appendMessage("Error",tcTest + ";" + tcMessage) ELSE this.appendMessage("Succes",tcTest + ";") ENDIF ENDPROC && verifica PROCEDURE appendMessage LPARAMETERS tcResult, tcMessage gcTestMessage = gcTestMessage + tcResult + CTAB + tcMessage + CRLF _CLIPTEXT = gcTestMessage ENDPROC ***================================================== FUNCTION test_referintedocumentenota LOCAL lnSucces *!* verific o nota de factura cu referinte llReferinteDocumente = ReferinteDocumenteNota(lnAnF, lnLunaF, lnCodF) && && odocumente.prg this.Verifica(llReferinteDocumente, .T., "test_referintedocumentenota-1", "Documentul are referinte") *!* verific o nota de incasare fara referinte llReferinteDocumente = ReferinteDocumenteNota(lnAnI, lnLunaI, lnCodI) && && odocumente.prg this.Verifica(llReferinteDocumente, .F., "test_referintedocumentenota-2", "Documentul nu are referinte") ENDFUNC && test_referintedocument ***================================================== FUNCTION test_referintedocument LOCAL lnSucces *!* verific un id_fact cu referinte llReferinteDocumente = ReferinteDocument(lnAnF, lnLunaF, lnCodF, lnIdFactF) && && odocumente.prg this.Verifica(llReferinteDocumente, .T., "test_referintedocument-1", "Documentul are referinte") *!* verific un id_fact fara referinte llReferinteDocumente = ReferinteDocument(lnAnI, lnLunaI, lnCodI, lnIdFactI) && && odocumente.prg this.Verifica(llReferinteDocumente, .F., "test_referintedocument-2", "Documentul nu are referinte") ENDFUNC && test_referintedocument ENDDEFINE