Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
157 lines
7.7 KiB
ABAP
157 lines
7.7 KiB
ABAP
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
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 bad_time_order FOR TESTING.
|
|
METHODS too_long FOR TESTING.
|
|
METHODS free_period FOR TESTING.
|
|
METHODS one_started_hour FOR TESTING.
|
|
METHODS two_started_hours FOR TESTING.
|
|
METHODS sunday_free FOR TESTING.
|
|
METHODS lost_ticket_flat FOR TESTING.
|
|
METHODS lost_ticket_on_sunday FOR TESTING.
|
|
METHODS discount_rounds FOR TESTING.
|
|
METHODS discount_rounds_up FOR TESTING.
|
|
METHODS daily_cap FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t02_hidden 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 bad_time_order.
|
|
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 too_long.
|
|
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.
|
|
|
|
METHOD free_period.
|
|
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_started_hour.
|
|
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_started_hours.
|
|
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_free.
|
|
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240107'
|
|
iv_entry_time = '100000'
|
|
iv_exit_date = '20240107'
|
|
iv_exit_time = '130000'
|
|
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_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 lost_ticket_on_sunday.
|
|
assert_result( is_result = mo_cut->calculate( iv_entry_date = '20240107'
|
|
iv_entry_time = '100000'
|
|
iv_exit_date = '20240107'
|
|
iv_exit_time = '120000'
|
|
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_rounds.
|
|
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 daily_cap.
|
|
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.
|
|
ENDCLASS.
|