Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
115 lines
3.8 KiB
ABAP
115 lines
3.8 KiB
ABAP
CLASS ltc_ferry_load_check DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}ferry_load_check.
|
|
DATA mo_error TYPE REF TO {{p}}cx_ferry_error.
|
|
METHODS setup.
|
|
METHODS valid_car_is_ok FOR TESTING.
|
|
METHODS empty_plate_rejected FOR TESTING.
|
|
METHODS hazard_in_car_rejected FOR TESTING.
|
|
METHODS weight_limit_rejected FOR TESTING.
|
|
METHODS plate_error_wins FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_ferry_load_check IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}ferry_load_check( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD valid_car_is_ok.
|
|
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
|
plate = 'B-AB 1234'
|
|
category = 'C'
|
|
weight_kg = 1500
|
|
length_cm = 450
|
|
height_cm = 150
|
|
hazard = abap_false ).
|
|
TRY.
|
|
mo_cut->check_loading( is_vehicle = ls_vehicle
|
|
iv_free_weight = 5000
|
|
iv_free_length = 2000
|
|
iv_max_height = 200 ).
|
|
CATCH {{p}}cx_ferry_error INTO mo_error.
|
|
cl_abap_unit_assert=>fail( msg = mo_error->reason ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD empty_plate_rejected.
|
|
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
|
plate = space
|
|
category = 'C'
|
|
weight_kg = 1500
|
|
length_cm = 450
|
|
height_cm = 150
|
|
hazard = abap_false ).
|
|
TRY.
|
|
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
|
cl_abap_unit_assert=>fail( msg = 'empty plate accepted' ).
|
|
CATCH {{p}}cx_ferry_error INTO mo_error.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_ferry_reason=>c_reason-plate
|
|
act = mo_error->reason ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD hazard_in_car_rejected.
|
|
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
|
plate = 'B-AB 1234'
|
|
category = 'C'
|
|
weight_kg = 1500
|
|
length_cm = 450
|
|
height_cm = 150
|
|
hazard = abap_true ).
|
|
TRY.
|
|
mo_cut->check_vehicle( is_vehicle = ls_vehicle ).
|
|
cl_abap_unit_assert=>fail( msg = 'hazard in car accepted' ).
|
|
CATCH {{p}}cx_ferry_error INTO mo_error.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_ferry_reason=>c_reason-hazard
|
|
act = mo_error->reason ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD weight_limit_rejected.
|
|
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
|
plate = 'B-AB 1234'
|
|
category = 'C'
|
|
weight_kg = 6000
|
|
length_cm = 450
|
|
height_cm = 150
|
|
hazard = abap_false ).
|
|
TRY.
|
|
mo_cut->check_loading( is_vehicle = ls_vehicle
|
|
iv_free_weight = 5000
|
|
iv_free_length = 2000
|
|
iv_max_height = 200 ).
|
|
cl_abap_unit_assert=>fail( msg = 'weight limit accepted' ).
|
|
CATCH {{p}}cx_ferry_error INTO mo_error.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_ferry_reason=>c_reason-weight_limit
|
|
act = mo_error->reason ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
|
|
METHOD plate_error_wins.
|
|
DATA(ls_vehicle) = VALUE {{p}}ferry_load_check=>ty_vehicle(
|
|
plate = space
|
|
category = 'C'
|
|
weight_kg = 9999
|
|
length_cm = 450
|
|
height_cm = 150
|
|
hazard = abap_false ).
|
|
TRY.
|
|
mo_cut->check_loading( is_vehicle = ls_vehicle
|
|
iv_free_weight = 1000
|
|
iv_free_length = 2000
|
|
iv_max_height = 200 ).
|
|
cl_abap_unit_assert=>fail( msg = 'empty plate accepted' ).
|
|
CATCH {{p}}cx_ferry_error INTO mo_error.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_ferry_reason=>c_reason-plate
|
|
act = mo_error->reason ).
|
|
ENDTRY.
|
|
ENDMETHOD.
|
|
ENDCLASS.
|