Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
73 lines
2.0 KiB
ABAP
73 lines
2.0 KiB
ABAP
CLASS {{p}}cine_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CONSTANTS: c_evening TYPE t VALUE '200000',
|
|
c_matinee TYPE t VALUE '160000'.
|
|
|
|
METHODS fee
|
|
IMPORTING iv_show TYPE string
|
|
iv_seats TYPE i
|
|
iv_time TYPE t
|
|
iv_cust TYPE string
|
|
RETURNING VALUE(rv_total) TYPE decfloat34.
|
|
|
|
METHODS adult_evening FOR TESTING.
|
|
METHODS matinee_discount FOR TESTING.
|
|
METHODS child_price FOR TESTING.
|
|
METHODS invalid_seats FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}cine_test IMPLEMENTATION.
|
|
|
|
METHOD fee.
|
|
CALL FUNCTION '{{P}}CINE_FEE_OLD'
|
|
EXPORTING
|
|
iv_show_type = iv_show
|
|
iv_seats = iv_seats
|
|
iv_show_time = iv_time
|
|
iv_cust_type = iv_cust
|
|
IMPORTING
|
|
ev_total = rv_total
|
|
EXCEPTIONS
|
|
invalid_input = 1
|
|
OTHERS = 2.
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD adult_evening.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( '9.50' )
|
|
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD matinee_discount.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( '7.25' )
|
|
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `ADULT` ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD child_price.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( '5.90' )
|
|
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `CHILD` ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_seats.
|
|
DATA lv_total TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}CINE_FEE_OLD'
|
|
EXPORTING
|
|
iv_show_type = `2D`
|
|
iv_seats = 0
|
|
iv_show_time = c_evening
|
|
iv_cust_type = `ADULT`
|
|
IMPORTING
|
|
ev_total = lv_total
|
|
EXCEPTIONS
|
|
invalid_input = 1
|
|
OTHERS = 2.
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
|
|
ENDCLASS.
|