89 lines
2.5 KiB
ABAP
89 lines
2.5 KiB
ABAP
CLASS {{p}}wood_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS fee_for
|
|
IMPORTING iv_type TYPE string
|
|
iv_volume TYPE decfloat34
|
|
iv_distance TYPE i DEFAULT 0
|
|
RETURNING VALUE(rv_fee) TYPE decfloat34.
|
|
METHODS beech_fee FOR TESTING.
|
|
METHODS delivery_charge FOR TESTING.
|
|
METHODS minimum_fee FOR TESTING.
|
|
METHODS mixed_skips FOR TESTING.
|
|
METHODS invalid_volume FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}wood_test IMPLEMENTATION.
|
|
METHOD fee_for.
|
|
DATA lv_skip TYPE abap_bool.
|
|
CALL FUNCTION '{{P}}WOOD_FEE'
|
|
EXPORTING
|
|
iv_wood_type = iv_type
|
|
iv_volume = iv_volume
|
|
iv_distance = iv_distance
|
|
IMPORTING
|
|
ev_skip = lv_skip
|
|
CHANGING
|
|
cv_fee = rv_fee
|
|
EXCEPTIONS
|
|
invalid_volume = 1
|
|
invalid_distance = 2
|
|
OTHERS = 3.
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
|
|
ENDMETHOD.
|
|
|
|
METHOD beech_fee.
|
|
DATA lv_exp TYPE decfloat34.
|
|
lv_exp = '240'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = fee_for( iv_type = 'BE' iv_volume = '2' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD delivery_charge.
|
|
DATA lv_exp TYPE decfloat34.
|
|
lv_exp = '244.50'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = fee_for( iv_type = 'BE' iv_volume = '2' iv_distance = 30 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD minimum_fee.
|
|
DATA lv_exp TYPE decfloat34.
|
|
lv_exp = '80'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = fee_for( iv_type = 'SP' iv_volume = '0.5' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD mixed_skips.
|
|
DATA lv_skip TYPE abap_bool.
|
|
DATA lv_fee TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
lv_exp = '7'.
|
|
lv_fee = '7'.
|
|
CALL FUNCTION '{{P}}WOOD_FEE'
|
|
EXPORTING
|
|
iv_wood_type = 'MX'
|
|
iv_volume = '2'
|
|
iv_distance = 10
|
|
IMPORTING
|
|
ev_skip = lv_skip
|
|
CHANGING
|
|
cv_fee = lv_fee.
|
|
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_fee ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_volume.
|
|
DATA lv_fee TYPE decfloat34.
|
|
CALL FUNCTION '{{P}}WOOD_FEE'
|
|
EXPORTING
|
|
iv_wood_type = 'BE'
|
|
iv_volume = '0'
|
|
iv_distance = 0
|
|
CHANGING
|
|
cv_fee = lv_fee
|
|
EXCEPTIONS
|
|
invalid_volume = 1
|
|
invalid_distance = 2
|
|
OTHERS = 3.
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|