Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
69 lines
2.2 KiB
ABAP
69 lines
2.2 KiB
ABAP
CLASS {{p}}theme_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS fee_for
|
|
IMPORTING
|
|
iv_type TYPE string
|
|
iv_tickets TYPE i
|
|
iv_date TYPE d
|
|
RETURNING VALUE(rv_total) TYPE decfloat34.
|
|
METHODS adult_price FOR TESTING.
|
|
METHODS child_price FOR TESTING.
|
|
METHODS group_discount FOR TESTING.
|
|
METHODS peak_season FOR TESTING.
|
|
METHODS invalid_type FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}theme_test IMPLEMENTATION.
|
|
METHOD fee_for.
|
|
CALL FUNCTION '{{P}}THEME_FEE'
|
|
EXPORTING
|
|
iv_visitor_type = iv_type
|
|
iv_tickets = iv_tickets
|
|
iv_date = iv_date
|
|
IMPORTING
|
|
ev_total_price = rv_total
|
|
EXCEPTIONS
|
|
invalid_visitor_type = 1
|
|
invalid_tickets = 2
|
|
OTHERS = 3.
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD adult_price.
|
|
DATA(lv_total) = fee_for( iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250115' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '45.50' ) act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD child_price.
|
|
DATA(lv_total) = fee_for( iv_type = 'CHILD' iv_tickets = 1 iv_date = '20250115' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '25.25' ) act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD group_discount.
|
|
DATA(lv_total) = fee_for( iv_type = 'ADULT' iv_tickets = 10 iv_date = '20250115' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '409.50' ) act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD peak_season.
|
|
DATA(lv_total) = fee_for( iv_type = 'ADULT' iv_tickets = 1 iv_date = '20250715' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '50.50' ) act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_type.
|
|
DATA lv_total TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}THEME_FEE'
|
|
EXPORTING
|
|
iv_visitor_type = 'STUDENT'
|
|
iv_tickets = 1
|
|
iv_date = '20250115'
|
|
IMPORTING
|
|
ev_total_price = lv_total
|
|
EXCEPTIONS
|
|
invalid_visitor_type = 1
|
|
OTHERS = 2.
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|