138 lines
5.3 KiB
ABAP
138 lines
5.3 KiB
ABAP
CLASS {{p}}t31_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
|
|
|
CONSTANTS c_screen_basic TYPE ty_price VALUE '89.00'.
|
|
CONSTANTS c_high_full TYPE ty_price VALUE '101.00'.
|
|
CONSTANTS c_mid_board TYPE ty_price VALUE '163.90'.
|
|
CONSTANTS c_minimum TYPE ty_price VALUE '25.00'.
|
|
CONSTANTS c_zero TYPE ty_price VALUE '0.00'.
|
|
CONSTANTS c_port_basic TYPE ty_price VALUE '49.00'.
|
|
CONSTANTS c_camera_express TYPE ty_price VALUE '74.00'.
|
|
CONSTANTS c_camera_full TYPE ty_price VALUE '59.20'.
|
|
CONSTANTS c_port_high TYPE ty_price VALUE '61.25'.
|
|
|
|
DATA mo_cut TYPE REF TO {{p}}phone_repair_pricer.
|
|
|
|
METHODS setup.
|
|
METHODS screen_basic_plain FOR TESTING.
|
|
METHODS screen_high_express_warranty FOR TESTING.
|
|
METHODS mid_device_surcharge FOR TESTING.
|
|
METHODS battery_minimum_charge FOR TESTING.
|
|
METHODS battery_warranty_minimum FOR TESTING.
|
|
METHODS unknown_repair_is_zero FOR TESTING.
|
|
METHODS unknown_repair_ignores_extras FOR TESTING.
|
|
METHODS unknown_device_is_basic FOR TESTING.
|
|
METHODS express_adds_fee FOR TESTING.
|
|
METHODS warranty_after_express FOR TESTING.
|
|
METHODS port_high_no_extras FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t31_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}phone_repair_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD screen_basic_plain.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_screen_basic
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'SCREEN'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD screen_high_express_warranty.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_high_full
|
|
act = mo_cut->calculate_price( iv_device = 'HIGH'
|
|
iv_repair = 'SCREEN'
|
|
iv_express = abap_true
|
|
iv_warranty = abap_true ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD mid_device_surcharge.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_mid_board
|
|
act = mo_cut->calculate_price( iv_device = 'MID'
|
|
iv_repair = 'BOARD'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD battery_minimum_charge.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_minimum
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'BATTERY'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD battery_warranty_minimum.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_minimum
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'BATTERY'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_true ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_repair_is_zero.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_zero
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'SPEAKER'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_repair_ignores_extras.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_zero
|
|
act = mo_cut->calculate_price( iv_device = 'HIGH'
|
|
iv_repair = 'SPEAKER'
|
|
iv_express = abap_true
|
|
iv_warranty = abap_true ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_device_is_basic.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_port_basic
|
|
act = mo_cut->calculate_price( iv_device = 'ULTRA'
|
|
iv_repair = 'PORT'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_adds_fee.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_camera_express
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'CAMERA'
|
|
iv_express = abap_true
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD warranty_after_express.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_camera_full
|
|
act = mo_cut->calculate_price( iv_device = 'BASIC'
|
|
iv_repair = 'CAMERA'
|
|
iv_express = abap_true
|
|
iv_warranty = abap_true ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD port_high_no_extras.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_port_high
|
|
act = mo_cut->calculate_price( iv_device = 'HIGH'
|
|
iv_repair = 'PORT'
|
|
iv_express = abap_false
|
|
iv_warranty = abap_false ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|