Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
111 lines
4.2 KiB
ABAP
111 lines
4.2 KiB
ABAP
CLASS ltc_insurance_premium DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}insurance_premium.
|
|
METHODS setup.
|
|
METHODS standard_premium FOR TESTING.
|
|
METHODS young_driver FOR TESTING.
|
|
METHODS senior_driver FOR TESTING.
|
|
METHODS high_power FOR TESTING.
|
|
METHODS very_high_power FOR TESTING.
|
|
METHODS low_power FOR TESTING.
|
|
METHODS claim_free_discount FOR TESTING.
|
|
METHODS claim_free_capped FOR TESTING.
|
|
METHODS minimum_premium FOR TESTING.
|
|
METHODS all_regions FOR TESTING.
|
|
METHODS invalid_region FOR TESTING.
|
|
METHODS invalid_inputs FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
CLASS ltc_insurance_premium IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}insurance_premium( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_premium.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 150
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD young_driver.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 225
|
|
act = mo_cut->calculate_premium( iv_age = 22 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD senior_driver.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 180
|
|
act = mo_cut->calculate_premium( iv_age = 70 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD high_power.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 195
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 120 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD very_high_power.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 240
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 200 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD low_power.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 135
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 40 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD claim_free_discount.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 180
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'B2' iv_claim_free_years = 2 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD claim_free_capped.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 140
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'B2' iv_claim_free_years = 10 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD minimum_premium.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 100
|
|
act = mo_cut->calculate_premium( iv_age = 25 iv_power_kw = 50 iv_region = 'A1' iv_claim_free_years = 6 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD all_regions.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 250 msg = 'C3'
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'C3' iv_claim_free_years = 0 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 300 msg = 'D4'
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'D4' iv_claim_free_years = 0 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 350 msg = 'E5'
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'E5' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_region.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'X9' iv_claim_free_years = 0 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_inputs.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0 msg = 'age too low'
|
|
act = mo_cut->calculate_premium( iv_age = 17 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0 msg = 'age too high'
|
|
act = mo_cut->calculate_premium( iv_age = 100 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0 msg = 'power too low'
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 0 iv_region = 'A1' iv_claim_free_years = 0 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0 msg = 'negative claim free years'
|
|
act = mo_cut->calculate_premium( iv_age = 30 iv_power_kw = 80 iv_region = 'A1' iv_claim_free_years = -1 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|