206 lines
6.8 KiB
ABAP
206 lines
6.8 KiB
ABAP
CLASS {{p}}t_stor_hidden DEFINITION
|
|
PUBLIC
|
|
FINAL
|
|
CREATE PUBLIC
|
|
FOR TESTING
|
|
DURATION SHORT
|
|
RISK LEVEL HARMLESS.
|
|
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}storage_pricer.
|
|
|
|
METHODS setup.
|
|
|
|
METHODS booking
|
|
IMPORTING iv_size TYPE i
|
|
iv_months TYPE i
|
|
iv_climate TYPE abap_bool
|
|
iv_insurance TYPE abap_bool
|
|
RETURNING VALUE(rs_booking) TYPE {{p}}storage_pricer=>ty_booking.
|
|
|
|
METHODS assert_price
|
|
IMPORTING iv_size TYPE i
|
|
iv_months TYPE i
|
|
iv_climate TYPE abap_bool
|
|
iv_insurance TYPE abap_bool
|
|
iv_expected TYPE {{p}}storage_pricer=>ty_amount
|
|
iv_msg TYPE string OPTIONAL.
|
|
|
|
METHODS rejects_zero_size FOR TESTING.
|
|
METHODS rejects_zero_months FOR TESTING.
|
|
METHODS rejects_negative FOR TESTING.
|
|
METHODS small_unit_short FOR TESTING.
|
|
METHODS size_band_limits FOR TESTING.
|
|
METHODS climate_surcharge FOR TESTING.
|
|
METHODS insurance_surcharge FOR TESTING.
|
|
METHODS discount_tiers FOR TESTING.
|
|
METHODS discount_thresholds FOR TESTING.
|
|
METHODS all_extras FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t_stor_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}storage_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD booking.
|
|
rs_booking-size_sqm = iv_size.
|
|
rs_booking-months = iv_months.
|
|
rs_booking-climate = iv_climate.
|
|
rs_booking-insurance = iv_insurance.
|
|
ENDMETHOD.
|
|
|
|
METHOD assert_price.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = iv_expected
|
|
act = mo_cut->calculate_price(
|
|
booking( iv_size = iv_size
|
|
iv_months = iv_months
|
|
iv_climate = iv_climate
|
|
iv_insurance = iv_insurance ) )
|
|
msg = iv_msg ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_zero_size.
|
|
assert_price( iv_size = 0
|
|
iv_months = 6
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '0.00'
|
|
iv_msg = `zero size` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_zero_months.
|
|
assert_price( iv_size = 5
|
|
iv_months = 0
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '0.00'
|
|
iv_msg = `zero months` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rejects_negative.
|
|
assert_price( iv_size = -3
|
|
iv_months = 4
|
|
iv_climate = abap_true
|
|
iv_insurance = abap_true
|
|
iv_expected = '0.00'
|
|
iv_msg = `negative size` ).
|
|
assert_price( iv_size = 4
|
|
iv_months = -1
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '0.00'
|
|
iv_msg = `negative months` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD small_unit_short.
|
|
assert_price( iv_size = 3
|
|
iv_months = 1
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '61.00' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD size_band_limits.
|
|
assert_price( iv_size = 5
|
|
iv_months = 2
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '159.00'
|
|
iv_msg = `size 5` ).
|
|
assert_price( iv_size = 6
|
|
iv_months = 2
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '157.00'
|
|
iv_msg = `size 6` ).
|
|
assert_price( iv_size = 15
|
|
iv_months = 2
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '364.00'
|
|
iv_msg = `size 15` ).
|
|
assert_price( iv_size = 16
|
|
iv_months = 2
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '307.00'
|
|
iv_msg = `size 16` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD climate_surcharge.
|
|
assert_price( iv_size = 4
|
|
iv_months = 3
|
|
iv_climate = abap_true
|
|
iv_insurance = abap_false
|
|
iv_expected = '241.00' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD insurance_surcharge.
|
|
assert_price( iv_size = 6
|
|
iv_months = 5
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_true
|
|
iv_expected = '391.00' ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_tiers.
|
|
assert_price( iv_size = 10
|
|
iv_months = 6
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '674.50'
|
|
iv_msg = `6 months` ).
|
|
assert_price( iv_size = 20
|
|
iv_months = 12
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '1963.00'
|
|
iv_msg = `12 months` ).
|
|
assert_price( iv_size = 20
|
|
iv_months = 24
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '3691.00'
|
|
iv_msg = `24 months` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD discount_thresholds.
|
|
assert_price( iv_size = 10
|
|
iv_months = 5
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '594.00'
|
|
iv_msg = `5 months` ).
|
|
assert_price( iv_size = 10
|
|
iv_months = 11
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '1220.75'
|
|
iv_msg = `11 months` ).
|
|
assert_price( iv_size = 10
|
|
iv_months = 23
|
|
iv_climate = abap_false
|
|
iv_insurance = abap_false
|
|
iv_expected = '2399.50'
|
|
iv_msg = `23 months` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD all_extras.
|
|
assert_price( iv_size = 5
|
|
iv_months = 6
|
|
iv_climate = abap_true
|
|
iv_insurance = abap_true
|
|
iv_expected = '573.25'
|
|
iv_msg = `medium unit` ).
|
|
assert_price( iv_size = 16
|
|
iv_months = 12
|
|
iv_climate = abap_true
|
|
iv_insurance = abap_true
|
|
iv_expected = '2524.60'
|
|
iv_msg = `large unit` ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|