CLASS ltc_water_bill DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2. DATA mo_cut TYPE REF TO {{p}}water_bill. METHODS setup. METHODS assert_bill IMPORTING iv_consumption TYPE i iv_days TYPE i iv_expected TYPE ty_amount. METHODS first_tier_only FOR TESTING. METHODS third_tier FOR TESTING. METHODS minimum_charge FOR TESTING. METHODS standing_charge_only FOR TESTING. METHODS sewage_is_rounded FOR TESTING. ENDCLASS. CLASS ltc_water_bill IMPLEMENTATION. METHOD setup. mo_cut = NEW {{p}}water_bill( ). ENDMETHOD. METHOD assert_bill. DATA(lv_actual) = CONV ty_amount( mo_cut->calculate( iv_consumption = iv_consumption iv_days = iv_days ) ). cl_abap_unit_assert=>assert_equals( exp = iv_expected act = lv_actual ). ENDMETHOD. METHOD first_tier_only. assert_bill( iv_consumption = 20 iv_days = 1 iv_expected = '68.91' ). ENDMETHOD. METHOD third_tier. assert_bill( iv_consumption = 60 iv_days = 1 iv_expected = '264.51' ). ENDMETHOD. METHOD minimum_charge. assert_bill( iv_consumption = 4 iv_days = 30 iv_expected = '35.00' ). ENDMETHOD. METHOD standing_charge_only. assert_bill( iv_consumption = 0 iv_days = 100 iv_expected = '45.00' ). ENDMETHOD. METHOD sewage_is_rounded. assert_bill( iv_consumption = 22 iv_days = 1 iv_expected = '78.04' ). ENDMETHOD. ENDCLASS.