Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
77 lines
2.7 KiB
ABAP
77 lines
2.7 KiB
ABAP
CLASS ltc_studio_pricer DEFINITION FINAL FOR TESTING
|
|
DURATION SHORT RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}studio_pricer.
|
|
|
|
METHODS setup.
|
|
METHODS assert_price
|
|
IMPORTING iv_expected TYPE {{p}}if_studio_pricer=>ty_amount
|
|
iv_actual TYPE {{p}}if_studio_pricer=>ty_amount.
|
|
METHODS room_a_three_hours FOR TESTING.
|
|
METHODS started_hour_counts FOR TESTING.
|
|
METHODS short_booking_one_hour FOR TESTING.
|
|
METHODS invalid_room_returns_zero FOR TESTING.
|
|
METHODS discount_five_bookings FOR TESTING.
|
|
METHODS discount_is_capped FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_studio_pricer IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}studio_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD assert_price.
|
|
cl_abap_unit_assert=>assert_equals( exp = iv_expected act = iv_actual ).
|
|
ENDMETHOD.
|
|
|
|
METHOD room_a_three_hours.
|
|
assert_price( iv_expected = '144.00'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'A'
|
|
iv_minutes = 180
|
|
iv_bookings = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD started_hour_counts.
|
|
assert_price( iv_expected = '96.00'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'A'
|
|
iv_minutes = 90
|
|
iv_bookings = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD short_booking_one_hour.
|
|
assert_price( iv_expected = '27.00'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'C'
|
|
iv_minutes = 15
|
|
iv_bookings = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_room_returns_zero.
|
|
assert_price( iv_expected = '0.00'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'X'
|
|
iv_minutes = 60
|
|
iv_bookings = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_five_bookings.
|
|
assert_price( iv_expected = '92.16'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'A'
|
|
iv_minutes = 120
|
|
iv_bookings = 5 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_is_capped.
|
|
assert_price( iv_expected = '30.60'
|
|
iv_actual = mo_cut->{{p}}if_studio_pricer~calculate(
|
|
iv_room = 'B'
|
|
iv_minutes = 30
|
|
iv_bookings = 30 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|