Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
43 lines
1.5 KiB
ABAP
43 lines
1.5 KiB
ABAP
CLASS {{p}}t20_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
|
|
CLASS-METHODS class_setup.
|
|
CLASS-METHODS class_teardown.
|
|
METHODS setup.
|
|
METHODS totals_of_one_play FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t20_test IMPLEMENTATION.
|
|
METHOD class_setup.
|
|
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_PLAY_STATS' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD class_teardown.
|
|
go_env->destroy( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD setup.
|
|
go_env->clear_doubles( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD totals_of_one_play.
|
|
DATA lt_play TYPE STANDARD TABLE OF {{p}}play WITH EMPTY KEY.
|
|
DATA lt_perf TYPE STANDARD TABLE OF {{p}}perf WITH EMPTY KEY.
|
|
lt_play = VALUE #( ( play_id = 'A' title = 'TEST' genre = 'DRAMA' director = 'X' ) ).
|
|
lt_perf = VALUE #( ( play_id = 'A' perf_no = 1 tickets_sold = 10 revenue = '1.00' )
|
|
( play_id = 'A' perf_no = 2 tickets_sold = 20 revenue = '2.00' ) ).
|
|
go_env->insert_test_data( lt_play ).
|
|
go_env->insert_test_data( lt_perf ).
|
|
SELECT SINGLE performance_count, total_tickets, total_revenue
|
|
FROM {{p}}i_play_stats
|
|
WHERE play_id = 'A' INTO @DATA(ls_row).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_row-performance_count ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 30 act = ls_row-total_tickets ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV decfloat34( 3 )
|
|
act = CONV decfloat34( ls_row-total_revenue ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|