Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
85 lines
3.3 KiB
ABAP
85 lines
3.3 KiB
ABAP
CLASS ltc_scrap_payout DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
TYPES ty_amount TYPE p LENGTH 10 DECIMALS 2.
|
|
|
|
DATA mo_cut TYPE REF TO {{p}}if_scrap_payout.
|
|
|
|
METHODS setup.
|
|
METHODS assert_payout
|
|
IMPORTING iv_material TYPE {{p}}if_scrap_payout=>ty_material
|
|
iv_weight_kg TYPE {{p}}if_scrap_payout=>ty_weight
|
|
iv_contamination TYPE i
|
|
iv_amount TYPE ty_amount
|
|
iv_reason TYPE {{p}}if_scrap_payout=>ty_reason.
|
|
|
|
METHODS copper_is_paid FOR TESTING.
|
|
METHODS contamination_reduces FOR TESTING.
|
|
METHODS rounding_is_commercial FOR TESTING.
|
|
METHODS unknown_material_rejected FOR TESTING.
|
|
METHODS zero_weight_rejected FOR TESTING.
|
|
METHODS dirty_too_high_rejected FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_scrap_payout IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}scrap_payout( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD assert_payout.
|
|
DATA(ls_payout) = mo_cut->calculate( iv_material = iv_material
|
|
iv_weight_kg = iv_weight_kg
|
|
iv_contamination = iv_contamination ).
|
|
cl_abap_unit_assert=>assert_equals( exp = iv_amount act = ls_payout-amount ).
|
|
cl_abap_unit_assert=>assert_equals( exp = iv_reason act = ls_payout-reason ).
|
|
ENDMETHOD.
|
|
|
|
METHOD copper_is_paid.
|
|
assert_payout( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 0
|
|
iv_amount = '420.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD contamination_reduces.
|
|
assert_payout( iv_material = {{p}}if_scrap_payout=>c_material-aluminium
|
|
iv_weight_kg = '50.000'
|
|
iv_contamination = 20
|
|
iv_amount = '44.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rounding_is_commercial.
|
|
assert_payout( iv_material = {{p}}if_scrap_payout=>c_material-brass
|
|
iv_weight_kg = '0.335'
|
|
iv_contamination = 0
|
|
iv_amount = '1.01'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_material_rejected.
|
|
assert_payout( iv_material = 'ZZ'
|
|
iv_weight_kg = '10.000'
|
|
iv_contamination = 0
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-material ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_weight_rejected.
|
|
assert_payout( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '0.000'
|
|
iv_contamination = 0
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-weight ).
|
|
ENDMETHOD.
|
|
|
|
METHOD dirty_too_high_rejected.
|
|
assert_payout( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 150
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-dirty ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|