139 lines
5.4 KiB
ABAP
139 lines
5.4 KiB
ABAP
CLASS {{p}}cobbler_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
|
|
PUBLIC SECTION.
|
|
INTERFACES {{p}}if_cobbler.
|
|
|
|
PRIVATE SECTION.
|
|
DATA mo_cut TYPE REF TO {{p}}if_cobbler.
|
|
|
|
METHODS setup.
|
|
METHODS service_codes FOR TESTING.
|
|
METHODS reason_codes FOR TESTING.
|
|
METHODS rule_values FOR TESTING.
|
|
METHODS base_prices FOR TESTING.
|
|
METHODS reason_type FOR TESTING.
|
|
METHODS service_type FOR TESTING.
|
|
METHODS amount_type FOR TESTING.
|
|
METHODS order_type FOR TESTING.
|
|
METHODS check_call FOR TESTING.
|
|
METHODS price_call FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}cobbler_hidden IMPLEMENTATION.
|
|
|
|
METHOD {{p}}if_cobbler~check.
|
|
rv_reason = {{p}}if_cobbler=>c_reason-ok.
|
|
ENDMETHOD.
|
|
|
|
METHOD {{p}}if_cobbler~price.
|
|
rv_price = 0.
|
|
ENDMETHOD.
|
|
|
|
METHOD setup.
|
|
mo_cut = me.
|
|
ENDMETHOD.
|
|
|
|
METHOD service_codes.
|
|
cl_abap_unit_assert=>assert_equals( exp = 'HEEL'
|
|
act = {{p}}if_cobbler=>c_service-heel ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SOLE'
|
|
act = {{p}}if_cobbler=>c_service-sole ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SEAM'
|
|
act = {{p}}if_cobbler=>c_service-seam ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'POLI'
|
|
act = {{p}}if_cobbler=>c_service-polish ).
|
|
ENDMETHOD.
|
|
|
|
METHOD reason_codes.
|
|
cl_abap_unit_assert=>assert_equals( exp = 'OK'
|
|
act = {{p}}if_cobbler=>c_reason-ok ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SERVICE'
|
|
act = {{p}}if_cobbler=>c_reason-service ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'PAIRS'
|
|
act = {{p}}if_cobbler=>c_reason-pairs ).
|
|
ENDMETHOD.
|
|
|
|
METHOD rule_values.
|
|
DATA lv_min_order TYPE {{p}}if_cobbler=>ty_amount.
|
|
lv_min_order = '8.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = 12
|
|
act = {{p}}if_cobbler=>c_rule-max_pairs ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 40
|
|
act = {{p}}if_cobbler=>c_rule-express_percent ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 10
|
|
act = {{p}}if_cobbler=>c_rule-member_percent ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_min_order
|
|
act = {{p}}if_cobbler=>c_rule-min_order ).
|
|
ENDMETHOD.
|
|
|
|
METHOD base_prices.
|
|
DATA lv_exp TYPE {{p}}if_cobbler=>ty_amount.
|
|
lv_exp = '12.50'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp
|
|
act = {{p}}if_cobbler=>c_base_price-heel ).
|
|
lv_exp = '25.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp
|
|
act = {{p}}if_cobbler=>c_base_price-sole ).
|
|
lv_exp = '8.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp
|
|
act = {{p}}if_cobbler=>c_base_price-seam ).
|
|
lv_exp = '6.50'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp
|
|
act = {{p}}if_cobbler=>c_base_price-polish ).
|
|
ENDMETHOD.
|
|
|
|
METHOD reason_type.
|
|
DATA(lo_elem) = CAST cl_abap_elemdescr(
|
|
cl_abap_typedescr=>describe_by_name( '{{P}}IF_COBBLER=>TY_REASON' ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 10 act = lo_elem->length ).
|
|
ENDMETHOD.
|
|
|
|
METHOD service_type.
|
|
DATA(lo_elem) = CAST cl_abap_elemdescr(
|
|
cl_abap_typedescr=>describe_by_name( '{{P}}IF_COBBLER=>TY_SERVICE' ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 4 act = lo_elem->length ).
|
|
ENDMETHOD.
|
|
|
|
METHOD amount_type.
|
|
DATA(lo_elem) = CAST cl_abap_elemdescr(
|
|
cl_abap_typedescr=>describe_by_name( '{{P}}IF_COBBLER=>TY_AMOUNT' ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 8 act = lo_elem->length ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = lo_elem->decimals ).
|
|
ENDMETHOD.
|
|
|
|
METHOD order_type.
|
|
DATA(lo_struct) = CAST cl_abap_structdescr(
|
|
cl_abap_typedescr=>describe_by_name( '{{P}}IF_COBBLER=>TY_ORDER' ) ).
|
|
DATA(lt_component) = lo_struct->get_components( ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines( lt_component ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'SERVICE' act = lt_component[ 1 ]-name ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'PAIRS' act = lt_component[ 2 ]-name ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'EXPRESS' act = lt_component[ 3 ]-name ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 'MEMBER' act = lt_component[ 4 ]-name ).
|
|
ENDMETHOD.
|
|
|
|
METHOD check_call.
|
|
DATA ls_order TYPE {{p}}if_cobbler=>ty_order.
|
|
ls_order-service = {{p}}if_cobbler=>c_service-heel.
|
|
ls_order-pairs = 2.
|
|
ls_order-express = abap_true.
|
|
ls_order-member = abap_false.
|
|
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_cobbler=>c_reason-ok
|
|
act = mo_cut->check( ls_order ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD price_call.
|
|
DATA ls_order TYPE {{p}}if_cobbler=>ty_order.
|
|
DATA lv_price TYPE {{p}}if_cobbler=>ty_amount.
|
|
DATA lv_zero TYPE {{p}}if_cobbler=>ty_amount.
|
|
ls_order-service = {{p}}if_cobbler=>c_service-polish.
|
|
ls_order-pairs = 1.
|
|
ls_order-express = abap_false.
|
|
ls_order-member = abap_false.
|
|
lv_price = mo_cut->price( ls_order ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_zero act = lv_price ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|