68 lines
2.8 KiB
ABAP
68 lines
2.8 KiB
ABAP
CLASS ltc_tool_hire DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
TYPES ty_amount TYPE {{p}}if_tool_hire=>ty_amount.
|
|
DATA mo_cut TYPE REF TO {{p}}if_tool_hire.
|
|
METHODS setup.
|
|
METHODS daily_rate FOR TESTING.
|
|
METHODS weekly_rate FOR TESTING.
|
|
METHODS monthly_rate FOR TESTING.
|
|
METHODS unknown_tool FOR TESTING.
|
|
METHODS zero_days FOR TESTING.
|
|
METHODS over_maximum FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_tool_hire IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}tool_hire( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD daily_rate.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 3 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '36.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD weekly_rate.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'S' iv_days = 10 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '45.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD monthly_rate.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'C' iv_days = 30 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '225.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_tool.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'X' iv_days = 5 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-unknown_tool
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_days.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-too_short
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD over_maximum.
|
|
DATA(ls_result) = mo_cut->calculate( iv_tool = 'D' iv_days = 100 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' )
|
|
act = ls_result-fee ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tool_hire=>c_reason-too_short
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|