74 lines
2.5 KiB
ABAP
74 lines
2.5 KiB
ABAP
CLASS {{p}}t41_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS msg_001 FOR TESTING.
|
|
METHODS msg_002 FOR TESTING.
|
|
METHODS msg_003 FOR TESTING.
|
|
METHODS msg_004 FOR TESTING.
|
|
METHODS msg_005 FOR TESTING.
|
|
METHODS exception_two_args FOR TESTING.
|
|
METHODS exception_one_arg FOR TESTING.
|
|
METHODS exception_is_static_check FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t41_test IMPLEMENTATION.
|
|
METHOD msg_001.
|
|
DATA lv_text TYPE string.
|
|
MESSAGE ID '{{P}}MSG' TYPE 'E' NUMBER '001' WITH 'ABAP101' INTO lv_text.
|
|
cl_abap_unit_assert=>assert_equals( exp = 'Course ABAP101 is fully booked' act = lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD msg_002.
|
|
DATA lv_text TYPE string.
|
|
MESSAGE ID '{{P}}MSG' TYPE 'E' NUMBER '002' WITH 'P-100' 'ABAP101' INTO lv_text.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Participant P-100 is already booked for course ABAP101'
|
|
act = lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD msg_003.
|
|
DATA lv_text TYPE string.
|
|
MESSAGE ID '{{P}}MSG' TYPE 'E' NUMBER '003' WITH 'ABAP101' '3' INTO lv_text.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Course ABAP101 has only 3 free seats left'
|
|
act = lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD msg_004.
|
|
DATA lv_text TYPE string.
|
|
MESSAGE ID '{{P}}MSG' TYPE 'E' NUMBER '004' WITH 'ABAP101' INTO lv_text.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Booking for course ABAP101 is confirmed'
|
|
act = lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD msg_005.
|
|
DATA lv_text TYPE string.
|
|
MESSAGE ID '{{P}}MSG' TYPE 'E' NUMBER '005' WITH 'ABAP101' '20250301' INTO lv_text.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Course ABAP101 was cancelled on 20250301'
|
|
act = lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD exception_two_args.
|
|
DATA(lo_cx) = NEW {{p}}cx_booking( iv_msgno = '002' iv_arg1 = 'P-100' iv_arg2 = 'ABAP101' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Participant P-100 is already booked for course ABAP101'
|
|
act = lo_cx->get_text( ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD exception_one_arg.
|
|
DATA(lo_cx) = NEW {{p}}cx_booking( iv_msgno = '004' iv_arg1 = 'ABAP101' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 'Booking for course ABAP101 is confirmed'
|
|
act = lo_cx->get_text( ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD exception_is_static_check.
|
|
DATA lo_cx TYPE REF TO cx_static_check.
|
|
lo_cx = NEW {{p}}cx_booking( iv_msgno = '001' iv_arg1 = 'ABAP101' ).
|
|
cl_abap_unit_assert=>assert_bound( lo_cx ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|