197 lines
8.9 KiB
ABAP
197 lines
8.9 KiB
ABAP
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CONSTANTS:
|
|
c_208 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '208.00',
|
|
c_312 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '312.00',
|
|
c_468 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '468.00',
|
|
c_513 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '513.00',
|
|
c_936 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '936.00',
|
|
c_1344 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '1344.00',
|
|
c_6451 TYPE {{p}}boat_hire_pricer=>ty_price VALUE '6451.20',
|
|
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_high_season FOR TESTING.
|
|
METHODS wide_long_hire FOR TESTING.
|
|
METHODS barge_low_season FOR TESTING.
|
|
METHODS lowercase_category FOR TESTING.
|
|
METHODS six_days_no_discount FOR TESTING.
|
|
METHODS crew_surcharge_boundary FOR TESTING.
|
|
METHODS max_bounds_ok FOR TESTING.
|
|
METHODS unknown_category FOR TESTING.
|
|
METHODS days_out_of_range FOR TESTING.
|
|
METHODS crew_out_of_range FOR TESTING.
|
|
METHODS month_out_of_range FOR TESTING.
|
|
METHODS reason_order FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}boat_hire_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD narrow_high_season.
|
|
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_long_hire.
|
|
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 = {{p}}boat_hire_pricer=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_1344 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD barge_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 = {{p}}boat_hire_pricer=>c_reason-ok
|
|
act = ls_result-reason ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_208 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD lowercase_category.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'narrow'
|
|
iv_days = 2
|
|
iv_crew = 2
|
|
iv_month = 6 ).
|
|
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_312 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD six_days_no_discount.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 6
|
|
iv_crew = 4
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_936 act = ls_result-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD crew_surcharge_boundary.
|
|
DATA(ls_six) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 6
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_468 act = ls_six-price ).
|
|
|
|
DATA(ls_seven) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 7
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = c_513 act = ls_seven-price ).
|
|
ENDMETHOD.
|
|
|
|
METHOD max_bounds_ok.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 28
|
|
iv_crew = 12
|
|
iv_month = 6 ).
|
|
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_6451 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 days_out_of_range.
|
|
DATA(ls_zero) = 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_zero-reason ).
|
|
|
|
DATA(ls_high) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 29
|
|
iv_crew = 4
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-days
|
|
act = ls_high-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD crew_out_of_range.
|
|
DATA(ls_zero) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 0
|
|
iv_month = 7 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-crew
|
|
act = ls_zero-reason ).
|
|
|
|
DATA(ls_high) = 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_high-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD month_out_of_range.
|
|
DATA(ls_zero) = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 4
|
|
iv_month = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-month
|
|
act = ls_zero-reason ).
|
|
|
|
DATA(ls_high) = 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_high-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD reason_order.
|
|
DATA(ls_result) = mo_cut->price( iv_category = 'CANOE'
|
|
iv_days = 0
|
|
iv_crew = 0
|
|
iv_month = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-category
|
|
act = ls_result-reason msg = `category first` ).
|
|
|
|
ls_result = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 0
|
|
iv_crew = 0
|
|
iv_month = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-days
|
|
act = ls_result-reason msg = `days before crew` ).
|
|
|
|
ls_result = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 0
|
|
iv_month = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-crew
|
|
act = ls_result-reason msg = `crew before month` ).
|
|
|
|
ls_result = mo_cut->price( iv_category = 'NARROW'
|
|
iv_days = 3
|
|
iv_crew = 4
|
|
iv_month = 0 ).
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}boat_hire_pricer=>c_reason-month
|
|
act = ls_result-reason msg = `month last` ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|