91 lines
3.6 KiB
ABAP
91 lines
3.6 KiB
ABAP
CLASS ltc_boat_hire_pricer DEFINITION FINAL FOR TESTING
|
|
DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CONSTANTS:
|
|
c_468 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '468.00',
|
|
c_1344 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '1344.00',
|
|
c_208 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '208.00',
|
|
c_zero TYPE {{p}}boat_hire_pricer=>ty_price VALUE 0.
|
|
|
|
DATA mo_cut TYPE REF TO {{p}}boat_hire_pricer.
|
|
|
|
METHODS setup.
|
|
METHODS narrow_ok FOR TESTING.
|
|
METHODS wide_discount FOR TESTING.
|
|
METHODS low_season FOR TESTING.
|
|
METHODS unknown_category FOR TESTING.
|
|
METHODS bad_days FOR TESTING.
|
|
METHODS bad_crew FOR TESTING.
|
|
METHODS bad_month FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_boat_hire_pricer IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}boat_hire_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD narrow_ok.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 4
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_468 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD wide_discount.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'WIDE'
|
|
iv_days = 7
|
|
iv_crew = 8
|
|
iv_month = 5 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_1344 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD low_season.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'BARGE'
|
|
iv_days = 1
|
|
iv_crew = 1
|
|
iv_month = 12 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_208 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_category.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'CANOE'
|
|
iv_days = 3
|
|
iv_crew = 4
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-category
|
|
act = ls_result-reason ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_zero act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD bad_days.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 0
|
|
iv_crew = 4
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-days
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD bad_crew.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 13
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-crew
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD bad_month.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 4
|
|
iv_month = 13 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-month
|
|
act = ls_result-reason ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|