124 lines
3.9 KiB
ABAP
124 lines
3.9 KiB
ABAP
CLASS {{p}}parking_hidden DEFINITION
|
|
PUBLIC
|
|
FINAL
|
|
CREATE PUBLIC
|
|
FOR TESTING
|
|
DURATION SHORT
|
|
RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}parking_pricer.
|
|
|
|
METHODS setup.
|
|
METHODS assert_fee
|
|
IMPORTING iv_expected TYPE {{p}}parking_pricer=>ty_fee
|
|
iv_minutes TYPE i
|
|
iv_vehicle TYPE {{p}}parking_pricer=>ty_vehicle
|
|
iv_lost TYPE abap_bool DEFAULT abap_false.
|
|
|
|
METHODS car_short_stay FOR TESTING.
|
|
METHODS grace_period_free FOR TESTING.
|
|
METHODS just_after_grace FOR TESTING.
|
|
METHODS negative_minutes_free FOR TESTING.
|
|
METHODS started_hour_rounds_up FOR TESTING.
|
|
METHODS motorcycle_and_van_rates FOR TESTING.
|
|
METHODS daily_caps FOR TESTING.
|
|
METHODS lost_ticket_fees FOR TESTING.
|
|
METHODS unknown_vehicle_free FOR TESTING.
|
|
METHODS unknown_vehicle_lost FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}parking_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}parking_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD assert_fee.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = iv_expected
|
|
act = mo_cut->calculate_fee( iv_minutes = iv_minutes
|
|
iv_vehicle = iv_vehicle
|
|
iv_lost_ticket = iv_lost ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD car_short_stay.
|
|
assert_fee( iv_expected = '4.00'
|
|
iv_minutes = 90
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
ENDMETHOD.
|
|
|
|
METHOD grace_period_free.
|
|
assert_fee( iv_expected = '0.00'
|
|
iv_minutes = 15
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
ENDMETHOD.
|
|
|
|
METHOD just_after_grace.
|
|
assert_fee( iv_expected = '2.00'
|
|
iv_minutes = 16
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
ENDMETHOD.
|
|
|
|
METHOD negative_minutes_free.
|
|
assert_fee( iv_expected = '0.00'
|
|
iv_minutes = -30
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
ENDMETHOD.
|
|
|
|
METHOD started_hour_rounds_up.
|
|
assert_fee( iv_expected = '4.00'
|
|
iv_minutes = 61
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
ENDMETHOD.
|
|
|
|
METHOD motorcycle_and_van_rates.
|
|
assert_fee( iv_expected = '2.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_motorcycle ).
|
|
assert_fee( iv_expected = '6.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_van ).
|
|
ENDMETHOD.
|
|
|
|
METHOD daily_caps.
|
|
assert_fee( iv_expected = '20.00'
|
|
iv_minutes = 900
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car ).
|
|
assert_fee( iv_expected = '24.00'
|
|
iv_minutes = 600
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_van ).
|
|
assert_fee( iv_expected = '10.00'
|
|
iv_minutes = 1200
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_motorcycle ).
|
|
ENDMETHOD.
|
|
|
|
METHOD lost_ticket_fees.
|
|
assert_fee( iv_expected = '25.00'
|
|
iv_minutes = 5
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_car
|
|
iv_lost = abap_true ).
|
|
assert_fee( iv_expected = '15.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_motorcycle
|
|
iv_lost = abap_true ).
|
|
assert_fee( iv_expected = '35.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = {{p}}parking_pricer=>c_vehicle_van
|
|
iv_lost = abap_true ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_vehicle_free.
|
|
assert_fee( iv_expected = '0.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = 'X' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_vehicle_lost.
|
|
assert_fee( iv_expected = '25.00'
|
|
iv_minutes = 120
|
|
iv_vehicle = 'X'
|
|
iv_lost = abap_true ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|