101 lines
3.9 KiB
ABAP
101 lines
3.9 KiB
ABAP
CLASS {{p}}t40_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}if_med_copay.
|
|
METHODS setup.
|
|
METHODS standard_minimum FOR TESTING.
|
|
METHODS standard_percentage FOR TESTING.
|
|
METHODS standard_cap FOR TESTING.
|
|
METHODS chronic_percentage FOR TESTING.
|
|
METHODS chronic_cap FOR TESTING.
|
|
METHODS exempt_pays_nothing FOR TESTING.
|
|
METHODS quantity_and_rounding FOR TESTING.
|
|
METHODS copay_not_above_total FOR TESTING.
|
|
METHODS rejects_zero_price FOR TESTING.
|
|
METHODS rejects_zero_quantity FOR TESTING.
|
|
METHODS rejects_unknown_tier FOR TESTING.
|
|
METHODS price_rule_comes_first FOR TESTING.
|
|
METHODS assert_case
|
|
IMPORTING iv_price TYPE {{p}}if_med_copay=>ty_amount
|
|
iv_quantity TYPE i
|
|
iv_tier TYPE {{p}}if_med_copay=>ty_tier
|
|
iv_exp_copay TYPE {{p}}if_med_copay=>ty_amount
|
|
iv_exp_reason TYPE {{p}}if_med_copay=>ty_reason
|
|
iv_msg TYPE string DEFAULT ''.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t40_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}med_copay( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_minimum.
|
|
assert_case( iv_price = '10.00' iv_quantity = 1 iv_tier = 'S'
|
|
iv_exp_copay = '5.00' iv_exp_reason = 'OK' iv_msg = `standard minimum` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_percentage.
|
|
assert_case( iv_price = '100.00' iv_quantity = 1 iv_tier = 'S'
|
|
iv_exp_copay = '30.00' iv_exp_reason = 'OK' iv_msg = `standard percentage` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_cap.
|
|
assert_case( iv_price = '500.00' iv_quantity = 1 iv_tier = 'S'
|
|
iv_exp_copay = '50.00' iv_exp_reason = 'OK' iv_msg = `standard cap` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD chronic_percentage.
|
|
assert_case( iv_price = '66.67' iv_quantity = 1 iv_tier = 'C'
|
|
iv_exp_copay = '6.67' iv_exp_reason = 'OK' iv_msg = `chronic percentage` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD chronic_cap.
|
|
assert_case( iv_price = '100.00' iv_quantity = 2 iv_tier = 'C'
|
|
iv_exp_copay = '10.00' iv_exp_reason = 'OK' iv_msg = `chronic cap` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD exempt_pays_nothing.
|
|
assert_case( iv_price = '100.00' iv_quantity = 3 iv_tier = 'E'
|
|
iv_exp_copay = '0.00' iv_exp_reason = 'OK' iv_msg = `exempt` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD quantity_and_rounding.
|
|
assert_case( iv_price = '8.33' iv_quantity = 3 iv_tier = 'S'
|
|
iv_exp_copay = '7.50' iv_exp_reason = 'OK' iv_msg = `rounding` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD copay_not_above_total.
|
|
assert_case( iv_price = '2.00' iv_quantity = 1 iv_tier = 'S'
|
|
iv_exp_copay = '2.00' iv_exp_reason = 'OK' iv_msg = `total cap` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_zero_price.
|
|
assert_case( iv_price = '0.00' iv_quantity = 1 iv_tier = 'S'
|
|
iv_exp_copay = '0.00' iv_exp_reason = 'PRICE' iv_msg = `zero price` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_zero_quantity.
|
|
assert_case( iv_price = '10.00' iv_quantity = 0 iv_tier = 'S'
|
|
iv_exp_copay = '0.00' iv_exp_reason = 'QUANTITY' iv_msg = `zero quantity` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_unknown_tier.
|
|
assert_case( iv_price = '10.00' iv_quantity = 1 iv_tier = 'X'
|
|
iv_exp_copay = '0.00' iv_exp_reason = 'TIER' iv_msg = `unknown tier` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD price_rule_comes_first.
|
|
assert_case( iv_price = '0.00' iv_quantity = 0 iv_tier = 'X'
|
|
iv_exp_copay = '0.00' iv_exp_reason = 'PRICE' iv_msg = `rule order` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD assert_case.
|
|
DATA(ls_result) = mo_cut->calculate( iv_price = iv_price
|
|
iv_quantity = iv_quantity
|
|
iv_tier = iv_tier ).
|
|
cl_abap_unit_assert=>assert_equals( exp = iv_exp_reason act = ls_result-reason msg = iv_msg ).
|
|
cl_abap_unit_assert=>assert_equals( exp = iv_exp_copay act = ls_result-copay msg = iv_msg ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|