All files / src zcl_abapgit_injector.clas.testclasses.abap

60.21% Statements 56/93
100% Branches 0/0
0% Functions 0/4
60.21% Lines 56/93

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 941x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                           1x 1x 1x 1x 1x 1x                 1x 1x       1x 1x                           1x 1x  
CLASS ltcl_abapgit_tadir_mock DEFINITION FOR TESTING.
 
  PUBLIC SECTION.
    INTERFACES zif_abapgit_tadir.
 
ENDCLASS.
 
CLASS ltcl_no_dependency_injection DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
 
  PRIVATE SECTION.
    METHODS:
      no_injection FOR TESTING RAISING cx_static_check.
 
ENDCLASS.
 
CLASS ltcl_simple_dependency_inject DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
 
  PRIVATE SECTION.
    METHODS:
      setup,
      teardown,
      simple_injection FOR TESTING RAISING cx_static_check.
 
ENDCLASS.
 
CLASS ltcl_abapgit_tadir_mock IMPLEMENTATION.
 
  METHOD zif_abapgit_tadir~get_object_package.
 
  ENDMETHOD.
 
  METHOD zif_abapgit_tadir~read.
 
  ENDMETHOD.
 
  METHOD zif_abapgit_tadir~read_single.
 
  ENDMETHOD.
 
ENDCLASS.
 
CLASS ltcl_no_dependency_injection IMPLEMENTATION.
 
  METHOD no_injection.

    DATA: li_tadir       TYPE REF TO zif_abapgit_tadir,
          lo_class_descr TYPE REF TO cl_abap_classdescr.

    li_tadir = zcl_abapgit_factory=>get_tadir( ).

    lo_class_descr ?= cl_abap_classdescr=>describe_by_object_ref( li_tadir ).

    cl_abap_unit_assert=>assert_equals(
      exp = '\CLASS=ZCL_ABAPGIT_TADIR'
      act = lo_class_descr->absolute_name ).

  ENDMETHOD.
 
ENDCLASS.
 
CLASS ltcl_simple_dependency_inject IMPLEMENTATION.
 
  METHOD setup.

    DATA lo_tadir_mock TYPE REF TO ltcl_abapgit_tadir_mock.

    CREATE OBJECT lo_tadir_mock.

    zcl_abapgit_injector=>set_tadir( lo_tadir_mock ).

  ENDMETHOD.
 
  METHOD teardown.
    DATA li_tadir TYPE REF TO zif_abapgit_tadir.
    zcl_abapgit_injector=>set_tadir( li_tadir ).
  ENDMETHOD.
 
  METHOD simple_injection.

    DATA: li_tadir       TYPE REF TO zif_abapgit_tadir,
          lo_class_descr TYPE REF TO cl_abap_classdescr.

    li_tadir = zcl_abapgit_factory=>get_tadir( ).

    lo_class_descr ?= cl_abap_classdescr=>describe_by_object_ref( li_tadir ).

    cl_abap_unit_assert=>assert_equals(
      exp = '\CLASS-POOL=ZCL_ABAPGIT_INJECTOR\CLASS=LTCL_ABAPGIT_TADIR_MOCK'
      act = lo_class_descr->absolute_name ).

  ENDMETHOD.
 
ENDCLASS.