Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
103 lines
4.4 KiB
ABAP
103 lines
4.4 KiB
ABAP
CLASS {{p}}t_ski_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS call
|
|
IMPORTING iv_equipment TYPE string
|
|
iv_days TYPE i
|
|
iv_customer TYPE string
|
|
iv_insurance TYPE abap_bool
|
|
EXPORTING ev_price TYPE decfloat34
|
|
ev_deposit TYPE decfloat34
|
|
ev_subrc TYPE sysubrc.
|
|
METHODS invalid_days FOR TESTING.
|
|
METHODS invalid_equipment FOR TESTING.
|
|
METHODS invalid_customer FOR TESTING.
|
|
METHODS adult_ski_one_day FOR TESTING.
|
|
METHODS child_boots_two_days FOR TESTING.
|
|
METHODS senior_snowboard_3d FOR TESTING.
|
|
METHODS adult_ski_7d_insurance FOR TESTING.
|
|
METHODS child_helmet_10d_ins FOR TESTING.
|
|
METHODS rounding_case FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t_ski_hidden IMPLEMENTATION.
|
|
METHOD call.
|
|
CALL FUNCTION '{{P}}SKI_RENTAL_OLD'
|
|
EXPORTING
|
|
iv_equipment = iv_equipment
|
|
iv_days = iv_days
|
|
iv_customer = iv_customer
|
|
iv_insurance = iv_insurance
|
|
IMPORTING
|
|
ev_price = ev_price
|
|
ev_deposit = ev_deposit
|
|
EXCEPTIONS
|
|
invalid_equipment = 1
|
|
invalid_days = 2
|
|
invalid_customer = 3
|
|
OTHERS = 4.
|
|
ev_subrc = sy-subrc.
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_days.
|
|
call( EXPORTING iv_equipment = 'SKI' iv_days = 0 iv_customer = 'ADULT' iv_insurance = abap_false
|
|
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_equipment.
|
|
call( EXPORTING iv_equipment = 'X' iv_days = 1 iv_customer = 'ADULT' iv_insurance = abap_false
|
|
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_customer.
|
|
call( EXPORTING iv_equipment = 'SKI' iv_days = 1 iv_customer = 'X' iv_insurance = abap_false
|
|
IMPORTING ev_subrc = DATA(lv_subrc) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD adult_ski_one_day.
|
|
call( EXPORTING iv_equipment = 'SKI' iv_days = 1 iv_customer = 'ADULT' iv_insurance = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 100 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
|
|
METHOD child_boots_two_days.
|
|
call( EXPORTING iv_equipment = 'BOOTS' iv_days = 2 iv_customer = 'CHILD' iv_insurance = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 10 ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 20 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
|
|
METHOD senior_snowboard_3d.
|
|
call( EXPORTING iv_equipment = 'SNOWBOARD' iv_days = 3 iv_customer = 'SENIOR' iv_insurance = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '68.40' ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 120 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
|
|
METHOD adult_ski_7d_insurance.
|
|
call( EXPORTING iv_equipment = 'SKI' iv_days = 7 iv_customer = 'ADULT' iv_insurance = abap_true
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '192.50' ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 150 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
|
|
METHOD child_helmet_10d_ins.
|
|
call( EXPORTING iv_equipment = 'HELMET' iv_days = 10 iv_customer = 'CHILD' iv_insurance = abap_true
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '72.50' ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 60 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rounding_case.
|
|
call( EXPORTING iv_equipment = 'SKI' iv_days = 3 iv_customer = 'CHILD' iv_insurance = abap_false
|
|
IMPORTING ev_price = DATA(lv_price) ev_deposit = DATA(lv_deposit) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '35.63' ) act = lv_price ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 100 ) act = lv_deposit ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|