156 lines
7.1 KiB
ABAP
156 lines
7.1 KiB
ABAP
CLASS {{p}}t61_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}skip_hire_calc.
|
|
METHODS setup.
|
|
METHODS empty_order_is_zero FOR TESTING.
|
|
METHODS small_order_minimum FOR TESTING.
|
|
METHODS base_prices_by_size FOR TESTING.
|
|
METHODS seven_days_included FOR TESTING.
|
|
METHODS extra_days_charged FOR TESTING.
|
|
METHODS hazardous_surcharge FOR TESTING.
|
|
METHODS permit_fee FOR TESTING.
|
|
METHODS invalid_containers_ignored FOR TESTING.
|
|
METHODS bulk_discount_five FOR TESTING.
|
|
METHODS discount_needs_five_valid FOR TESTING.
|
|
METHODS container_charge_direct FOR TESTING.
|
|
METHODS discount_boundaries FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t61_hidden IMPLEMENTATION.
|
|
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}skip_hire_calc( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD empty_order_is_zero.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers( ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '0.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD small_order_minimum.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '120.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_prices_by_size.
|
|
DATA(lt_medium) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'MEDIUM' days = 1 hazardous = abap_false permit = abap_false ) ).
|
|
DATA(lt_large) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'LARGE' days = 1 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '140.00' )
|
|
act = mo_cut->hire_charge( lt_medium ) msg = `MEDIUM` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '200.00' )
|
|
act = mo_cut->hire_charge( lt_large ) msg = `LARGE` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD seven_days_included.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'MEDIUM' days = 7 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '140.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD extra_days_charged.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'MEDIUM' days = 10 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '176.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD hazardous_surcharge.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_true permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '150.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD permit_fee.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_true ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '135.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_containers_ignored.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'HUGE' days = 3 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 0 hazardous = abap_false permit = abap_false )
|
|
( size = 'LARGE' days = -2 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '0.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD bulk_discount_five.
|
|
DATA(lt_containers) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '405.00' )
|
|
act = mo_cut->hire_charge( lt_containers ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_needs_five_valid.
|
|
DATA(lt_four) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false ) ).
|
|
DATA(lt_with_invalid) = VALUE {{p}}skip_hire_calc=>tt_containers(
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false )
|
|
( size = 'HUGE' days = 5 hazardous = abap_false permit = abap_false ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '360.00' )
|
|
act = mo_cut->hire_charge( lt_four ) msg = `four containers` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '360.00' )
|
|
act = mo_cut->hire_charge( lt_with_invalid ) msg = `invalid row not counted` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD container_charge_direct.
|
|
DATA(ls_small) = VALUE {{p}}skip_hire_calc=>ty_container(
|
|
size = 'SMALL' days = 1 hazardous = abap_false permit = abap_false ).
|
|
DATA(ls_large) = VALUE {{p}}skip_hire_calc=>ty_container(
|
|
size = 'LARGE' days = 10 hazardous = abap_false permit = abap_false ).
|
|
DATA(ls_no_days) = VALUE {{p}}skip_hire_calc=>ty_container(
|
|
size = 'MEDIUM' days = 0 hazardous = abap_false permit = abap_false ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '90.00' )
|
|
act = mo_cut->container_charge( ls_small ) msg = `SMALL one day` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '248.00' )
|
|
act = mo_cut->container_charge( ls_large ) msg = `LARGE ten days` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}skip_hire_calc=>ty_amount( '0.00' )
|
|
act = mo_cut->container_charge( ls_no_days ) msg = `no days` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_boundaries.
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = mo_cut->bulk_discount( 0 ) msg = `none` ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = mo_cut->bulk_discount( 4 ) msg = `four` ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 10 act = mo_cut->bulk_discount( 5 ) msg = `five` ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 10 act = mo_cut->bulk_discount( 9 ) msg = `nine` ).
|
|
ENDMETHOD.
|
|
|
|
ENDCLASS.
|