Files
abap-llm/tasks_gen/eval/G0101/reference/park_fee_calculator.testclasses.abap

144 lines
7.1 KiB
ABAP

CLASS ltc_park_fee DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}if_park_fee.
METHODS setup.
METHODS assert_result
IMPORTING is_result TYPE {{p}}if_park_fee=>ty_result
iv_fee TYPE {{p}}if_park_fee=>ty_amount
iv_reason TYPE {{p}}if_park_fee=>ty_reason.
METHODS free_period_is_free FOR TESTING.
METHODS one_hour_costs_250 FOR TESTING.
METHODS two_hours_cost_500 FOR TESTING.
METHODS sunday_is_free FOR TESTING.
METHODS lost_ticket_is_flat FOR TESTING.
METHODS discount_is_rounded FOR TESTING.
METHODS discount_rounds_up FOR TESTING.
METHODS fee_is_capped FOR TESTING.
METHODS exit_before_entry FOR TESTING.
METHODS long_parking FOR TESTING.
ENDCLASS.
CLASS ltc_park_fee IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}park_fee_calculator( ).
ENDMETHOD.
METHOD assert_result.
cl_abap_unit_assert=>assert_equals( exp = iv_fee act = is_result-fee ).
cl_abap_unit_assert=>assert_equals( exp = iv_reason act = is_result-reason ).
ENDMETHOD.
METHOD free_period_is_free.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '100015'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '0.00'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD one_hour_costs_250.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '103000'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '2.50'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD two_hours_cost_500.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '110100'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '5.00'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD sunday_is_free.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240107'
iv_entry_time = '090000'
iv_exit_date = '20240107'
iv_exit_time = '120000'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '0.00'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD lost_ticket_is_flat.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '100500'
iv_lost_ticket = abap_true
iv_discount = abap_false )
iv_fee = '45.00'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD discount_is_rounded.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '110100'
iv_lost_ticket = abap_false
iv_discount = abap_true )
iv_fee = '3.75'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD discount_rounds_up.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240108'
iv_exit_time = '103000'
iv_lost_ticket = abap_false
iv_discount = abap_true )
iv_fee = '1.88'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD fee_is_capped.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '060000'
iv_exit_date = '20240109'
iv_exit_time = '120000'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '60.00'
iv_reason = {{p}}if_park_fee=>c_reason-ok ).
ENDMETHOD.
METHOD exit_before_entry.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '120000'
iv_exit_date = '20240108'
iv_exit_time = '110000'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '0.00'
iv_reason = {{p}}if_park_fee=>c_reason-bad_time ).
ENDMETHOD.
METHOD long_parking.
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240108'
iv_entry_time = '100000'
iv_exit_date = '20240208'
iv_exit_time = '100100'
iv_lost_ticket = abap_false
iv_discount = abap_false )
iv_fee = '0.00'
iv_reason = {{p}}if_park_fee=>c_reason-too_long ).
ENDMETHOD.
ENDCLASS.