88 lines
3.2 KiB
ABAP
88 lines
3.2 KiB
ABAP
CLASS ltc_frame_pricer DEFINITION FINAL 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_small TYPE ty_amount VALUE '37.84',
|
|
c_exp_oversized TYPE ty_amount VALUE '119.40',
|
|
c_exp_gold TYPE ty_amount VALUE '271.00',
|
|
c_exp_zero TYPE ty_amount VALUE '0.00'.
|
|
DATA mo_cut TYPE REF TO {{p}}frame_pricer.
|
|
METHODS setup.
|
|
METHODS standard_order FOR TESTING.
|
|
METHODS premium_order FOR TESTING.
|
|
METHODS small_frame FOR TESTING.
|
|
METHODS oversized_frame FOR TESTING.
|
|
METHODS no_setup_fee_for_five FOR TESTING.
|
|
METHODS invalid_input FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS ltc_frame_pricer IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}frame_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD standard_order.
|
|
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_order.
|
|
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 small_frame.
|
|
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 oversized_frame.
|
|
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 no_setup_fee_for_five.
|
|
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 invalid_input.
|
|
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 ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|