Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
128 lines
5.8 KiB
ABAP
128 lines
5.8 KiB
ABAP
CLASS {{p}}theme_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS call
|
|
IMPORTING
|
|
iv_type TYPE string
|
|
iv_tickets TYPE i
|
|
iv_date TYPE d
|
|
EXPORTING
|
|
ev_unit TYPE decfloat34
|
|
ev_total TYPE decfloat34
|
|
ev_discount TYPE decfloat34
|
|
ev_subrc TYPE sysubrc.
|
|
METHODS peak_season_surcharge FOR TESTING.
|
|
METHODS no_surcharge_off_peak FOR TESTING.
|
|
METHODS discount_tiers FOR TESTING.
|
|
METHODS discount_rounding FOR TESTING.
|
|
METHODS base_prices FOR TESTING.
|
|
METHODS invalid_visitor_type FOR TESTING.
|
|
METHODS invalid_tickets FOR TESTING.
|
|
METHODS unit_price_with_surcharge FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}theme_hidden IMPLEMENTATION.
|
|
METHOD call.
|
|
CALL FUNCTION '{{P}}THEME_FEE'
|
|
EXPORTING
|
|
iv_visitor_type = iv_type
|
|
iv_tickets = iv_tickets
|
|
iv_date = iv_date
|
|
IMPORTING
|
|
ev_unit_price = ev_unit
|
|
ev_total_price = ev_total
|
|
ev_discount = ev_discount
|
|
EXCEPTIONS
|
|
invalid_visitor_type = 1
|
|
invalid_tickets = 2
|
|
OTHERS = 3.
|
|
ev_subrc = sy-subrc.
|
|
ENDMETHOD.
|
|
|
|
METHOD peak_season_surcharge.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250715'
|
|
IMPORTING ev_unit = DATA(lv_jul) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '50.50' ) act = lv_jul ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250801'
|
|
IMPORTING ev_unit = DATA(lv_aug) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '50.50' ) act = lv_aug ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250630'
|
|
IMPORTING ev_unit = DATA(lv_jun) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '50.50' ) act = lv_jun ).
|
|
ENDMETHOD.
|
|
|
|
METHOD no_surcharge_off_peak.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_unit = DATA(lv_jan) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_jan ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20251215'
|
|
IMPORTING ev_unit = DATA(lv_dec) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_dec ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250531'
|
|
IMPORTING ev_unit = DATA(lv_may) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_may ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_tiers.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 9 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_d9) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_d9 ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 10 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_d10) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_d10 ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 19 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_d19) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '86.45' ) act = lv_d19 ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 20 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_d20) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '136.50' ) act = lv_d20 ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 25 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_d25) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '170.63' ) act = lv_d25 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_rounding.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 25 iv_date = '20250115'
|
|
IMPORTING ev_discount = DATA(lv_disc) ev_total = DATA(lv_total) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '170.63' ) act = lv_disc ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '966.87' ) act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_prices.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_unit = DATA(lv_adult) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_adult ).
|
|
call( EXPORTING iv_type = 'CHILD' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_unit = DATA(lv_child) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '25.25' ) act = lv_child ).
|
|
call( EXPORTING iv_type = 'SENIOR' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_unit = DATA(lv_senior) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '30.75' ) act = lv_senior ).
|
|
call( EXPORTING iv_type = 'FAMILY' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_unit = DATA(lv_family) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '40.00' ) act = lv_family ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_visitor_type.
|
|
call( EXPORTING iv_type = 'STUDENT' iv_tickets = 1 iv_date = '20250115'
|
|
IMPORTING ev_subrc = DATA(lv_rc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_tickets.
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = 0 iv_date = '20250115'
|
|
IMPORTING ev_subrc = DATA(lv_rc0) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc0 ).
|
|
call( EXPORTING iv_type = 'ADULT' iv_tickets = -1 iv_date = '20250115'
|
|
IMPORTING ev_subrc = DATA(lv_rc1) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rc1 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unit_price_with_surcharge.
|
|
call( EXPORTING iv_type = 'CHILD' iv_tickets = 1 iv_date = '20250704'
|
|
IMPORTING ev_unit = DATA(lv_unit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '30.25' ) act = lv_unit ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|