172 lines
6.7 KiB
ABAP
172 lines
6.7 KiB
ABAP
CLASS {{p}}frame_pricer_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
TYPES ty_amount TYPE p LENGTH 9 DECIMALS 2.
|
|
CONSTANTS:
|
|
c_exp_standard TYPE ty_amount VALUE '59.20',
|
|
c_exp_premium TYPE ty_amount VALUE '155.00',
|
|
c_exp_gold TYPE ty_amount VALUE '271.00',
|
|
c_exp_small TYPE ty_amount VALUE '37.84',
|
|
c_exp_perimeter TYPE ty_amount VALUE '34.00',
|
|
c_exp_oversized TYPE ty_amount VALUE '119.40',
|
|
c_exp_area TYPE ty_amount VALUE '96.00',
|
|
c_exp_qty_five TYPE ty_amount VALUE '115.00',
|
|
c_exp_qty_four TYPE ty_amount VALUE '107.00',
|
|
c_exp_zero TYPE ty_amount VALUE '0.00'.
|
|
DATA mo_cut TYPE REF TO {{p}}frame_pricer.
|
|
METHODS setup.
|
|
METHODS standard_frame FOR TESTING.
|
|
METHODS premium_frame FOR TESTING.
|
|
METHODS gold_frame_no_glass FOR TESTING.
|
|
METHODS small_frame_surcharge FOR TESTING.
|
|
METHODS perimeter_at_limit FOR TESTING.
|
|
METHODS oversized_surcharge FOR TESTING.
|
|
METHODS area_at_limit FOR TESTING.
|
|
METHODS quantity_five_no_setup FOR TESTING.
|
|
METHODS quantity_four_setup FOR TESTING.
|
|
METHODS invalid_dimensions FOR TESTING.
|
|
METHODS invalid_moulding FOR TESTING.
|
|
METHODS invalid_glass FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}frame_pricer_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}frame_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_frame.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_standard
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD premium_frame.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_premium
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'P'
|
|
iv_glass = 'A'
|
|
iv_quantity = 2 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD gold_frame_no_glass.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_gold
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'G'
|
|
iv_glass = 'N'
|
|
iv_quantity = 5 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD small_frame_surcharge.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_small
|
|
act = mo_cut->calculate_price( iv_width_cm = 10
|
|
iv_height_cm = 14
|
|
iv_moulding = 'S'
|
|
iv_glass = 'N'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD perimeter_at_limit.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_perimeter
|
|
act = mo_cut->calculate_price( iv_width_cm = 10
|
|
iv_height_cm = 15
|
|
iv_moulding = 'S'
|
|
iv_glass = 'N'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD oversized_surcharge.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_oversized
|
|
act = mo_cut->calculate_price( iv_width_cm = 150
|
|
iv_height_cm = 140
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD area_at_limit.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_area
|
|
act = mo_cut->calculate_price( iv_width_cm = 100
|
|
iv_height_cm = 200
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD quantity_five_no_setup.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_qty_five
|
|
act = mo_cut->calculate_price( iv_width_cm = 20
|
|
iv_height_cm = 30
|
|
iv_moulding = 'S'
|
|
iv_glass = 'N'
|
|
iv_quantity = 5 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD quantity_four_setup.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_qty_four
|
|
act = mo_cut->calculate_price( iv_width_cm = 20
|
|
iv_height_cm = 30
|
|
iv_moulding = 'S'
|
|
iv_glass = 'N'
|
|
iv_quantity = 4 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_dimensions.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_zero
|
|
act = mo_cut->calculate_price( iv_width_cm = 0
|
|
iv_height_cm = 40
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) msg = `width` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_zero
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 0
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) msg = `height` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_zero
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'S'
|
|
iv_glass = 'S'
|
|
iv_quantity = 0 ) msg = `quantity` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_moulding.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_zero
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'X'
|
|
iv_glass = 'S'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD invalid_glass.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_exp_zero
|
|
act = mo_cut->calculate_price( iv_width_cm = 30
|
|
iv_height_cm = 40
|
|
iv_moulding = 'S'
|
|
iv_glass = 'X'
|
|
iv_quantity = 1 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|