Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
245 lines
10 KiB
ABAP
245 lines
10 KiB
ABAP
CLASS {{p}}e05_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
CONSTANTS:
|
|
c_base_min TYPE {{p}}cake_pricer=>ty_price VALUE '15.00',
|
|
c_size_fee TYPE {{p}}cake_pricer=>ty_price VALUE '16.80',
|
|
c_clamped TYPE {{p}}cake_pricer=>ty_price VALUE '38.50',
|
|
c_layers TYPE {{p}}cake_pricer=>ty_price VALUE '25.50',
|
|
c_lay_clamp TYPE {{p}}cake_pricer=>ty_price VALUE '29.50',
|
|
c_vanilla TYPE {{p}}cake_pricer=>ty_price VALUE '19.50',
|
|
c_choc TYPE {{p}}cake_pricer=>ty_price VALUE '20.50',
|
|
c_fruit TYPE {{p}}cake_pricer=>ty_price VALUE '22.00',
|
|
c_plain TYPE {{p}}cake_pricer=>ty_price VALUE '16.50',
|
|
c_flowers TYPE {{p}}cake_pricer=>ty_price VALUE '22.80',
|
|
c_sugar TYPE {{p}}cake_pricer=>ty_price VALUE '28.80',
|
|
c_photo TYPE {{p}}cake_pricer=>ty_price VALUE '26.30',
|
|
c_photo_lo TYPE {{p}}cake_pricer=>ty_price VALUE '20.50',
|
|
c_photo_hi TYPE {{p}}cake_pricer=>ty_price VALUE '33.20',
|
|
c_unknown TYPE {{p}}cake_pricer=>ty_price VALUE '23.00',
|
|
c_express TYPE {{p}}cake_pricer=>ty_price VALUE '29.50',
|
|
c_round TYPE {{p}}cake_pricer=>ty_price VALUE '39.13'.
|
|
|
|
DATA mo_cut TYPE REF TO {{p}}cake_pricer.
|
|
METHODS setup.
|
|
METHODS base_min_price FOR TESTING.
|
|
METHODS size_rules FOR TESTING.
|
|
METHODS layer_fee FOR TESTING.
|
|
METHODS layers_clamped FOR TESTING.
|
|
METHODS filling_fee FOR TESTING.
|
|
METHODS decoration_fee FOR TESTING.
|
|
METHODS photo_needs_size FOR TESTING.
|
|
METHODS unknown_codes FOR TESTING.
|
|
METHODS express_exact FOR TESTING.
|
|
METHODS express_rounds FOR TESTING.
|
|
METHODS express_at_min FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}e05_hidden IMPLEMENTATION.
|
|
METHOD setup.
|
|
mo_cut = NEW {{p}}cake_pricer( ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_min_price.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_base_min
|
|
act = mo_cut->calculate_price( iv_size = 16
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `base` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD size_rules.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_clamped
|
|
act = mo_cut->calculate_price( iv_size = 10
|
|
iv_layers = 3
|
|
iv_filling = 'F'
|
|
iv_decoration = 'S'
|
|
iv_express = abap_false )
|
|
msg = `clamped` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_clamped
|
|
act = mo_cut->calculate_price( iv_size = 16
|
|
iv_layers = 3
|
|
iv_filling = 'F'
|
|
iv_decoration = 'S'
|
|
iv_express = abap_false )
|
|
msg = `min size` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_size_fee
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `size fee` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD layer_fee.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_layers
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 4
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `layers` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD layers_clamped.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_lay_clamp
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 0
|
|
iv_filling = 'F'
|
|
iv_decoration = 'S'
|
|
iv_express = abap_false )
|
|
msg = `zero layers` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_lay_clamp
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 1
|
|
iv_filling = 'F'
|
|
iv_decoration = 'S'
|
|
iv_express = abap_false )
|
|
msg = `one layer` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD filling_fee.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_vanilla
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 2
|
|
iv_filling = 'V'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `vanilla` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_choc
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 2
|
|
iv_filling = 'C'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `chocolate` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_fruit
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 2
|
|
iv_filling = 'F'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `fruit` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_plain
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 2
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `none` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD decoration_fee.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_size_fee
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_false )
|
|
msg = `no deco` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_flowers
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'F'
|
|
iv_express = abap_false )
|
|
msg = `flowers` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_sugar
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'S'
|
|
iv_express = abap_false )
|
|
msg = `sugar` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_photo
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'P'
|
|
iv_express = abap_false )
|
|
msg = `photo` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD photo_needs_size.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_photo_lo
|
|
act = mo_cut->calculate_price( iv_size = 20
|
|
iv_layers = 2
|
|
iv_filling = 'C'
|
|
iv_decoration = 'P'
|
|
iv_express = abap_false )
|
|
msg = `too small` ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_photo_hi
|
|
act = mo_cut->calculate_price( iv_size = 24
|
|
iv_layers = 2
|
|
iv_filling = 'C'
|
|
iv_decoration = 'P'
|
|
iv_express = abap_false )
|
|
msg = `large enough` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD unknown_codes.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_unknown
|
|
act = mo_cut->calculate_price( iv_size = 30
|
|
iv_layers = 1
|
|
iv_filling = 'X'
|
|
iv_decoration = 'Z'
|
|
iv_express = abap_false )
|
|
msg = `unknown codes` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_exact.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_express
|
|
act = mo_cut->calculate_price( iv_size = 22
|
|
iv_layers = 1
|
|
iv_filling = 'C'
|
|
iv_decoration = 'F'
|
|
iv_express = abap_true )
|
|
msg = `express` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_rounds.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_round
|
|
act = mo_cut->calculate_price( iv_size = 26
|
|
iv_layers = 2
|
|
iv_filling = 'C'
|
|
iv_decoration = 'F'
|
|
iv_express = abap_true )
|
|
msg = `express rounded` ).
|
|
ENDMETHOD.
|
|
|
|
METHOD express_at_min.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = c_base_min
|
|
act = mo_cut->calculate_price( iv_size = 16
|
|
iv_layers = 1
|
|
iv_filling = 'N'
|
|
iv_decoration = 'N'
|
|
iv_express = abap_true )
|
|
msg = `express at minimum` ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|