CLASS {{p}}sewer_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. METHODS call IMPORTING iv_litres TYPE i iv_km TYPE i DEFAULT 0 iv_mains TYPE abap_bool DEFAULT abap_false iv_fee TYPE decfloat34 DEFAULT 7 EXPORTING ev_skip TYPE abap_bool ev_fee TYPE decfloat34 ev_subrc TYPE sysubrc. METHODS base_fee FOR TESTING. METHODS volume_steps FOR TESTING. METHODS travel_fee FOR TESTING. METHODS travel_cap FOR TESTING. METHODS large_tank FOR TESTING. METHODS fee_cap FOR TESTING. METHODS mains_sewer_skips FOR TESTING. METHODS skip_false FOR TESTING. METHODS invalid_litres FOR TESTING. ENDCLASS. CLASS {{p}}sewer_hidden IMPLEMENTATION. METHOD call. ev_fee = iv_fee. CALL FUNCTION '{{P}}SEWER_FEE' EXPORTING iv_tank_litres = iv_litres iv_distance_km = iv_km iv_mains_sewer = iv_mains IMPORTING ev_skip = ev_skip CHANGING cv_fee = ev_fee EXCEPTIONS invalid_litres = 1 OTHERS = 2. ev_subrc = sy-subrc. ENDMETHOD. METHOD base_fee. call( EXPORTING iv_litres = 800 IMPORTING ev_fee = DATA(lv_fee) ev_skip = DATA(lv_skip) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 75 ) act = lv_fee ). cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ). ENDMETHOD. METHOD volume_steps. call( EXPORTING iv_litres = 1001 IMPORTING ev_fee = DATA(lv_a) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 95 ) act = lv_a ). call( EXPORTING iv_litres = 1500 IMPORTING ev_fee = DATA(lv_b) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 95 ) act = lv_b ). call( EXPORTING iv_litres = 1501 IMPORTING ev_fee = DATA(lv_c) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 115 ) act = lv_c ). ENDMETHOD. METHOD travel_fee. call( EXPORTING iv_litres = 1000 iv_km = 10 IMPORTING ev_fee = DATA(lv_fee) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 90 ) act = lv_fee ). ENDMETHOD. METHOD travel_cap. call( EXPORTING iv_litres = 1000 iv_km = 50 IMPORTING ev_fee = DATA(lv_fee) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 135 ) act = lv_fee ). ENDMETHOD. METHOD large_tank. call( EXPORTING iv_litres = 20000 IMPORTING ev_fee = DATA(lv_fee) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 835 ) act = lv_fee ). ENDMETHOD. METHOD fee_cap. call( EXPORTING iv_litres = 30000 IMPORTING ev_fee = DATA(lv_fee) ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 900 ) act = lv_fee ). ENDMETHOD. METHOD mains_sewer_skips. call( EXPORTING iv_litres = 2000 iv_km = 20 iv_mains = abap_true iv_fee = 7 IMPORTING ev_skip = DATA(lv_skip) ev_fee = DATA(lv_fee) ). cl_abap_unit_assert=>assert_true( lv_skip ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 7 ) act = lv_fee ). ENDMETHOD. METHOD skip_false. call( EXPORTING iv_litres = 1000 iv_km = 5 IMPORTING ev_skip = DATA(lv_skip) ). cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ). ENDMETHOD. METHOD invalid_litres. call( EXPORTING iv_litres = 0 IMPORTING ev_subrc = DATA(lv_rc) ). cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ). ENDMETHOD. ENDCLASS.