Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
131 lines
4.6 KiB
ABAP
131 lines
4.6 KiB
ABAP
CLASS {{p}}t_f01_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
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 check
|
|
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_clean FOR TESTING.
|
|
METHODS copper_contaminated FOR TESTING.
|
|
METHODS steel_clean FOR TESTING.
|
|
METHODS brass_half_dirty FOR TESTING.
|
|
METHODS rounds_amount FOR TESTING.
|
|
METHODS rounds_half_up FOR TESTING.
|
|
METHODS material_lower_case FOR TESTING.
|
|
METHODS unknown_material FOR TESTING.
|
|
METHODS zero_weight FOR TESTING.
|
|
METHODS dirty_too_high FOR TESTING.
|
|
METHODS fully_contaminated FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t_f01_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}scrap_payout( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD check.
|
|
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_clean.
|
|
check( 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 copper_contaminated.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '250.500'
|
|
iv_contamination = 20
|
|
iv_amount = '841.68'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD steel_clean.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-steel
|
|
iv_weight_kg = '1000.000'
|
|
iv_contamination = 0
|
|
iv_amount = '300.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD brass_half_dirty.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-brass
|
|
iv_weight_kg = '10.000'
|
|
iv_contamination = 50
|
|
iv_amount = '15.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rounds_amount.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-aluminium
|
|
iv_weight_kg = '3.333'
|
|
iv_contamination = 0
|
|
iv_amount = '3.67'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rounds_half_up.
|
|
check( 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 material_lower_case.
|
|
check( iv_material = 'cu'
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 0
|
|
iv_amount = '420.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_material.
|
|
check( iv_material = 'XX'
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 0
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-material ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_weight.
|
|
check( 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.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 101
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-dirty ).
|
|
ENDMETHOD.
|
|
|
|
METHOD fully_contaminated.
|
|
check( iv_material = {{p}}if_scrap_payout=>c_material-copper
|
|
iv_weight_kg = '100.000'
|
|
iv_contamination = 100
|
|
iv_amount = '0.00'
|
|
iv_reason = {{p}}if_scrap_payout=>c_reason-ok ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|