sync SVN r18057
This commit is contained in:
196
teste/test_chk_amort_introducere.prg
Normal file
196
teste/test_chk_amort_introducere.prg
Normal file
@@ -0,0 +1,196 @@
|
||||
* test_chk_amort_introducere.prg
|
||||
* Test headless pentru "bifa amortizare maxim deductibila la introducere imobilizare
|
||||
* corporala" (frm_introducere din Clase\oimobilizari.vc2).
|
||||
*
|
||||
* Verifica:
|
||||
* 1) formularul frm_introducere se instantiaza fara eroare (obiectul chk_amort_max_deductibil
|
||||
* e adaugat corect, metoda .Valid se leaga)
|
||||
* 2) la introducere noua (tnTipModificare=1): bifa NEACTIVA, campul read-only, valoarea NULL
|
||||
* (toata amortizarea deductibila)
|
||||
* 3) activarea bifei -> campul devine editabil, valoarea 0; dezactivarea -> NULL din nou
|
||||
* 4) expresia de salvare pcAmortMaxDeductibil -> 'NULL' la debifat / valoarea la bifat
|
||||
*
|
||||
* Rulare: vfp9.exe -A -T "test_chk_amort_introducere.prg"
|
||||
* (DO test_init_env_auto_roaimob din acelasi folder, cu DSN CENTRAL / schema MARIUSM_AUTO)
|
||||
* Verdict in test_chk_amort_introducere_log.txt (langa acest fisier).
|
||||
|
||||
SET SAFETY OFF
|
||||
SET TALK OFF
|
||||
SET DELETED ON
|
||||
SET EXACT ON
|
||||
SET CENTURY ON
|
||||
SET DATE DMY
|
||||
SET NULLDISPLAY TO ''
|
||||
CLOSE DATABASES
|
||||
|
||||
PUBLIC gcUILog
|
||||
gcUILog = "D:\ROA\ROAIMOB\teste\test_chk_amort_introducere_log.txt"
|
||||
STRTOFILE("START " + TTOC(DATETIME()) + CHR(13)+CHR(10), gcUILog)
|
||||
|
||||
ON ERROR DO PrErrLocal WITH ERROR(), MESSAGE(), PROGRAM(), LINENO()
|
||||
ON SHUTDOWN QUIT
|
||||
|
||||
TRY
|
||||
DO "D:\ROA\ROAIMOB\teste\test_init_env_auto_roaimob.prg" WITH 'CENTRAL', 'MARIUSM_AUTO', 'ROMFASTSOFT'
|
||||
IF gnHandle <= 0
|
||||
DO PrLogLocal WITH 'FAIL: conectare Oracle esuata (gnHandle=' + TRANSFORM(gnHandle) + ')'
|
||||
QUIT
|
||||
ENDIF
|
||||
DO PrLogLocal WITH 'mediu ROAIMOB initializat'
|
||||
|
||||
*-- variabile globale de care depinde formularul
|
||||
PUBLIC gnPa, gnPC
|
||||
gnPa = 2
|
||||
gnPC = 2
|
||||
gnIdSucursala = gnIdFirma
|
||||
|
||||
*-- cursorii pe care ii folosesc combobox-urile formularului (v_tipuri_amort, v_tipuri_imob, cote_TVA)
|
||||
IF USED('v_tipuri_amort')
|
||||
USE IN v_tipuri_amort
|
||||
ENDIF
|
||||
CREATE CURSOR v_tipuri_amort (denumire C(30), id_tip_amortizare N(4))
|
||||
INSERT INTO v_tipuri_amort (denumire, id_tip_amortizare) VALUES ('LINIARA', 1)
|
||||
INSERT INTO v_tipuri_amort (denumire, id_tip_amortizare) VALUES ('ACCELERATA', 2)
|
||||
|
||||
IF USED('v_tipuri_imob')
|
||||
USE IN v_tipuri_imob
|
||||
ENDIF
|
||||
CREATE CURSOR v_tipuri_imob (denumire C(30), id_tip_imobilizare N(4))
|
||||
INSERT INTO v_tipuri_imob (denumire, id_tip_imobilizare) VALUES ('CORPORALA', 1)
|
||||
|
||||
IF USED('cote_TVA')
|
||||
USE IN cote_TVA
|
||||
ENDIF
|
||||
CREATE CURSOR cote_TVA (procent N(6,2), descriere C(40), id_proc_tva N(4), proc_tva N(6,2))
|
||||
INSERT INTO cote_TVA (procent, descriere, id_proc_tva, proc_tva) VALUES (1.19, 'standard', 1, 1.19)
|
||||
|
||||
*-- stub poGeneratorNumere pentru apelul poGeneratorNumere.aloca_numar din Init (tnTipModificare=1)
|
||||
PUBLIC poGeneratorNumere
|
||||
poGeneratorNumere = CREATEOBJECT('stub_generator')
|
||||
|
||||
*-- poMF trebuie sa existe ca variabila (formularul il foloseste in metode)
|
||||
PUBLIC poMF
|
||||
poMF = CREATEOBJECT('custom')
|
||||
|
||||
DO PrLogLocal WITH 'cursori + stubs pregatite'
|
||||
|
||||
*-- instantiez formularul real (introducere imobilizare CORPORALA = tnTip 1, modificare 1)
|
||||
LOCAL ofrm
|
||||
ofrm = CREATEOBJECT('frm_intro_test', 1, 1)
|
||||
DO PrLogLocal WITH 'frm_introducere instantiat OK'
|
||||
DO PrLogLocal WITH 'chk exista: ' + TRANSFORM(PEMSTATUS(ofrm, 'chk_amort_max_deductibil', 5))
|
||||
|
||||
*-- 1) stare initiala la introducere noua (INANTE de orice modificare)
|
||||
LOCAL lcStare1
|
||||
lcStare1 = 'bifa=' + TRANSFORM(ofrm.chk_amort_max_deductibil.Value) + ;
|
||||
' readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
|
||||
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
|
||||
DO PrLogLocal WITH 'stare initiala: ' + lcStare1
|
||||
|
||||
*-- stare initiala trebuie sa fie: bifa .F., readonly .T., valoare NULL
|
||||
LOCAL llBifaNeactiva, llReadOnly, llNull, llOk
|
||||
llBifaNeactiva = (ofrm.chk_amort_max_deductibil.Value = .F.)
|
||||
llReadOnly = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .T.)
|
||||
llNull = ISNULL(ofrm.clb_amort_max_deductibil.text_simplu1.Value)
|
||||
llOk = (m.llBifaNeactiva AND m.llReadOnly AND m.llNull)
|
||||
IF m.llOk
|
||||
DO PrLogLocal WITH 'PASS: stare initiala corecta (bifa neactiva, camp read-only, valoare NULL = toata amortizarea deductibila)'
|
||||
ELSE
|
||||
DO PrLogLocal WITH 'FAIL: stare initiala incorecta (bifa=' + TRANSFORM(m.llBifaNeactiva) + ;
|
||||
' readonly=' + TRANSFORM(m.llReadOnly) + ' null=' + TRANSFORM(m.llNull) + ')'
|
||||
ENDIF
|
||||
|
||||
*-- 2) activez bifa -> camp editabil, valoare 0
|
||||
ofrm.chk_amort_max_deductibil.Value = .T.
|
||||
ofrm.chk_amort_max_deductibil.Valid()
|
||||
LOCAL llToggleOk
|
||||
llToggleOk = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .F.) ;
|
||||
AND (ofrm.clb_amort_max_deductibil.text_simplu1.Value = 0)
|
||||
DO PrLogLocal WITH 'dupa activare bifa: readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
|
||||
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
|
||||
IF m.llToggleOk
|
||||
DO PrLogLocal WITH 'PASS: activarea bifei face campul editabil cu valoare 0'
|
||||
ELSE
|
||||
DO PrLogLocal WITH 'FAIL: activarea bifei nu a activat campul corect'
|
||||
m.llOk = .F.
|
||||
ENDIF
|
||||
|
||||
*-- 3) dezactivez bifa -> NULL din nou, camp read-only
|
||||
ofrm.chk_amort_max_deductibil.Value = .F.
|
||||
ofrm.chk_amort_max_deductibil.Valid()
|
||||
LOCAL llDezOk
|
||||
llDezOk = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .T.) ;
|
||||
AND ISNULL(ofrm.clb_amort_max_deductibil.text_simplu1.Value)
|
||||
DO PrLogLocal WITH 'dupa dezactivare bifa: readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
|
||||
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
|
||||
IF m.llDezOk
|
||||
DO PrLogLocal WITH 'PASS: dezactivarea bifei revine la NULL + read-only'
|
||||
ELSE
|
||||
DO PrLogLocal WITH 'FAIL: dezactivarea bifei nu a revenit la NULL'
|
||||
m.llOk = .F.
|
||||
ENDIF
|
||||
|
||||
*-- 4) expresia de salvare pcAmortMaxDeductibil
|
||||
LOCAL pcAmortMaxDeductibil, pnAmortMaxDeductibil, lcSaveNull, lcSaveVal
|
||||
ofrm.chk_amort_max_deductibil.Value = .F.
|
||||
ofrm.chk_amort_max_deductibil.Valid()
|
||||
pnAmortMaxDeductibil = ofrm.clb_amort_max_deductibil.text_simplu1.Value
|
||||
pcAmortMaxDeductibil = IIF(ISNULL(m.pnAmortMaxDeductibil), 'NULL', ALLTRIM(STR(m.pnAmortMaxDeductibil, 14, gnPC)))
|
||||
lcSaveNull = m.pcAmortMaxDeductibil
|
||||
DO PrLogLocal WITH 'pcAmortMaxDeductibil (debifat) = [' + lcSaveNull + ']'
|
||||
|
||||
ofrm.chk_amort_max_deductibil.Value = .T.
|
||||
ofrm.chk_amort_max_deductibil.Valid()
|
||||
ofrm.clb_amort_max_deductibil.text_simplu1.Value = 1500
|
||||
pnAmortMaxDeductibil = ofrm.clb_amort_max_deductibil.text_simplu1.Value
|
||||
pcAmortMaxDeductibil = IIF(ISNULL(m.pnAmortMaxDeductibil), 'NULL', ALLTRIM(STR(m.pnAmortMaxDeductibil, 14, gnPC)))
|
||||
lcSaveVal = m.pcAmortMaxDeductibil
|
||||
DO PrLogLocal WITH 'pcAmortMaxDeductibil (bifat=1500) = [' + lcSaveVal + ']'
|
||||
|
||||
LOCAL llSaveOk
|
||||
llSaveOk = (m.lcSaveNull == 'NULL') AND (VAL(m.lcSaveVal) = 1500)
|
||||
IF m.llSaveOk
|
||||
DO PrLogLocal WITH 'PASS: pcAmortMaxDeductibil corect (NULL la debifat, valoare la bifat)'
|
||||
ELSE
|
||||
DO PrLogLocal WITH 'FAIL: pcAmortMaxDeductibil incorect (debifat=[' + m.lcSaveNull + '] bifat=[' + m.lcSaveVal + '])'
|
||||
m.llOk = .F.
|
||||
ENDIF
|
||||
|
||||
DO PrLogLocal WITH 'VERDICT: ' + IIF(m.llOk, 'PASS', 'FAIL')
|
||||
DO PrLogLocal WITH 'GATA'
|
||||
CATCH TO loExcMain
|
||||
DO PrLogLocal WITH 'CATCH ErrorNo=' + TRANSFORM(loExcMain.ErrorNo) + ' Message=' + loExcMain.Message + ;
|
||||
' Proc=' + loExcMain.Procedure + ' Line=' + TRANSFORM(loExcMain.LineNo) + ' [' + loExcMain.LineContents + ']'
|
||||
ENDTRY
|
||||
|
||||
QUIT
|
||||
|
||||
PROCEDURE PrErrLocal
|
||||
LPARAMETERS tnErr, tcMsg, tcProg, tnLine
|
||||
DO PrLogLocal WITH 'ON ERROR ' + TRANSFORM(tnErr) + ' [' + tcProg + ':' + TRANSFORM(tnLine) + '] ' + tcMsg
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE PrLogLocal
|
||||
LPARAMETERS tcMsg
|
||||
SET SAFETY OFF
|
||||
LOCAL lcL
|
||||
lcL = IIF(FILE(gcUILog), FILETOSTR(gcUILog), '')
|
||||
STRTOFILE(lcL + tcMsg + CHR(13)+CHR(10), gcUILog)
|
||||
ENDPROC
|
||||
|
||||
* DEFINE CLASS la finalul fisierului (capcana: DEFINE CLASS nu poate sta la mijloc)
|
||||
DEFINE CLASS stub_generator AS custom
|
||||
PROCEDURE aloca_numar
|
||||
LPARAMETERS tnTipDoc, tnTip
|
||||
RETURN 1
|
||||
ENDPROC
|
||||
PROCEDURE ResetAll
|
||||
ENDPROC
|
||||
ENDDEFINE
|
||||
|
||||
DEFINE CLASS frm_intro_test AS frm_introducere
|
||||
PROCEDURE Load
|
||||
* suprascriu Load-ul parinte (_frm_base), care ar deschide o fereastra de atentionare
|
||||
* daca cselect/ccursor sunt goale
|
||||
ENDPROC
|
||||
ENDDEFINE
|
||||
Reference in New Issue
Block a user