85 lines
2.6 KiB
ABAP
85 lines
2.6 KiB
ABAP
CLASS ltc_inspection_checker DEFINITION FINAL FOR TESTING
|
|
DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}if_inspection_check.
|
|
|
|
METHODS setup.
|
|
METHODS reason_of
|
|
IMPORTING iv_plate TYPE string DEFAULT `B-AB 1234`
|
|
iv_make TYPE string DEFAULT `VW`
|
|
iv_first_reg TYPE d DEFAULT '20150101'
|
|
iv_check_date TYPE d DEFAULT '20250615'
|
|
iv_mileage_km TYPE i DEFAULT 100000
|
|
iv_brake_pct TYPE i DEFAULT 60
|
|
iv_exhaust_ppm TYPE i DEFAULT 500
|
|
RETURNING VALUE(rv_reason) TYPE {{p}}if_inspection_check=>ty_reason.
|
|
|
|
METHODS ok_vehicle FOR TESTING.
|
|
METHODS empty_plate FOR TESTING.
|
|
METHODS empty_make FOR TESTING.
|
|
METHODS future_reg_date FOR TESTING.
|
|
METHODS old_vehicle FOR TESTING.
|
|
METHODS weak_brakes FOR TESTING.
|
|
METHODS high_exhaust FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_inspection_checker IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}inspection_checker( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD reason_of.
|
|
rv_reason = mo_cut->check_vehicle(
|
|
iv_plate = iv_plate
|
|
iv_make = iv_make
|
|
iv_first_reg = iv_first_reg
|
|
iv_check_date = iv_check_date
|
|
iv_mileage_km = iv_mileage_km
|
|
iv_brake_pct = iv_brake_pct
|
|
iv_exhaust_ppm = iv_exhaust_ppm ).
|
|
ENDMETHOD.
|
|
|
|
METHOD ok_vehicle.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-ok
|
|
act = reason_of( ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD empty_plate.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-no_plate
|
|
act = reason_of( iv_plate = ` ` ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD empty_make.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-no_make
|
|
act = reason_of( iv_make = ` ` ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD future_reg_date.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-reg_date
|
|
act = reason_of( iv_first_reg = '20300101' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD old_vehicle.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-too_old
|
|
act = reason_of( iv_first_reg = '19800101' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD weak_brakes.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-brakes
|
|
act = reason_of( iv_brake_pct = 20 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD high_exhaust.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = {{p}}if_inspection_check=>c_reason-exhaust
|
|
act = reason_of( iv_exhaust_ppm = 5000 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|