CLASS {{p}}tenancy_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. TYPES ty_amount TYPE {{p}}if_tenancy_check=>ty_amount. DATA mo_cut TYPE REF TO {{p}}if_tenancy_check. METHODS setup. METHODS ok_application FOR TESTING. METHODS bad_rent FOR TESTING. METHODS bad_income FOR TESTING. METHODS no_person FOR TESTING. METHODS overcrowded FOR TESTING. METHODS bad_employment FOR TESTING. METHODS income_too_low FOR TESTING. METHODS pets_raise_factor FOR TESTING. METHODS deposit_without_pets FOR TESTING. METHODS deposit_with_pets FOR TESTING. METHODS constants_and_types FOR TESTING. ENDCLASS. CLASS {{p}}tenancy_hidden IMPLEMENTATION. METHOD setup. mo_cut = NEW {{p}}tenancy_checker( ). ENDMETHOD. METHOD ok_application. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ok act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) ). ENDMETHOD. METHOD bad_rent. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-rent act = mo_cut->check( iv_rent = CONV ty_amount( 0 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) msg = `zero rent` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-rent act = mo_cut->check( iv_rent = CONV ty_amount( -100 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) msg = `negative rent` ). ENDMETHOD. METHOD bad_income. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-income act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 0 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) msg = `zero income` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-income act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( -500 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) msg = `negative income` ). ENDMETHOD. METHOD no_person. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-persons act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 0 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) ). ENDMETHOD. METHOD overcrowded. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-capacity act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 5 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) ). ENDMETHOD. METHOD bad_employment. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-employment act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 2 iv_employment = 'X' iv_pets = abap_false ) ). ENDMETHOD. METHOD income_too_low. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ratio act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 3500 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_false ) msg = `permanent needs 3x` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ratio act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4700 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-fixed iv_pets = abap_false ) msg = `fixed term needs 4x` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ratio act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 5900 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-self iv_pets = abap_false ) msg = `self employed needs 5x` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ok act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 6000 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-self iv_pets = abap_false ) msg = `self employed is ok` ). ENDMETHOD. METHOD pets_raise_factor. cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ratio act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4000 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_true ) msg = `pets need 4x` ). cl_abap_unit_assert=>assert_equals( exp = {{p}}if_tenancy_check=>c_reason-ok act = mo_cut->check( iv_rent = CONV ty_amount( 1200 ) iv_income = CONV ty_amount( 4800 ) iv_rooms = 2 iv_persons = 2 iv_employment = {{p}}if_tenancy_check=>c_employment-permanent iv_pets = abap_true ) msg = `pets with 4x is ok` ). ENDMETHOD. METHOD deposit_without_pets. cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( 2400 ) act = mo_cut->deposit( iv_rent = CONV ty_amount( 1200 ) iv_pets = abap_false ) ). cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( 0 ) act = mo_cut->deposit( iv_rent = CONV ty_amount( 0 ) iv_pets = abap_false ) msg = `zero rent` ). ENDMETHOD. METHOD deposit_with_pets. cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( 3600 ) act = mo_cut->deposit( iv_rent = CONV ty_amount( 1200 ) iv_pets = abap_true ) ). cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( 0 ) act = mo_cut->deposit( iv_rent = CONV ty_amount( 0 ) iv_pets = abap_true ) msg = `zero rent` ). ENDMETHOD. METHOD constants_and_types. cl_abap_unit_assert=>assert_equals( exp = 'OK' act = {{p}}if_tenancy_check=>c_reason-ok ). cl_abap_unit_assert=>assert_equals( exp = 'RENT' act = {{p}}if_tenancy_check=>c_reason-rent ). cl_abap_unit_assert=>assert_equals( exp = 'INCOME' act = {{p}}if_tenancy_check=>c_reason-income ). cl_abap_unit_assert=>assert_equals( exp = 'PERSONS' act = {{p}}if_tenancy_check=>c_reason-persons ). cl_abap_unit_assert=>assert_equals( exp = 'CAPACITY' act = {{p}}if_tenancy_check=>c_reason-capacity ). cl_abap_unit_assert=>assert_equals( exp = 'EMPLOYMENT' act = {{p}}if_tenancy_check=>c_reason-employment ). cl_abap_unit_assert=>assert_equals( exp = 'RATIO' act = {{p}}if_tenancy_check=>c_reason-ratio ). cl_abap_unit_assert=>assert_equals( exp = 'P' act = {{p}}if_tenancy_check=>c_employment-permanent ). cl_abap_unit_assert=>assert_equals( exp = 'F' act = {{p}}if_tenancy_check=>c_employment-fixed ). cl_abap_unit_assert=>assert_equals( exp = 'S' act = {{p}}if_tenancy_check=>c_employment-self ). DATA lv_reason TYPE {{p}}if_tenancy_check=>ty_reason. DATA lv_employment TYPE {{p}}if_tenancy_check=>ty_employment. DATA lv_amount TYPE {{p}}if_tenancy_check=>ty_amount. cl_abap_unit_assert=>assert_equals( exp = 10 act = cl_abap_typedescr=>describe_by_data( lv_reason )->length ). cl_abap_unit_assert=>assert_equals( exp = cl_abap_typedescr=>typekind_char act = cl_abap_typedescr=>describe_by_data( lv_reason )->type_kind ). cl_abap_unit_assert=>assert_equals( exp = 1 act = cl_abap_typedescr=>describe_by_data( lv_employment )->length ). cl_abap_unit_assert=>assert_equals( exp = cl_abap_typedescr=>typekind_char act = cl_abap_typedescr=>describe_by_data( lv_employment )->type_kind ). cl_abap_unit_assert=>assert_equals( exp = 8 act = cl_abap_typedescr=>describe_by_data( lv_amount )->length ). cl_abap_unit_assert=>assert_equals( exp = 2 act = cl_abap_typedescr=>describe_by_data( lv_amount )->decimals ). cl_abap_unit_assert=>assert_equals( exp = cl_abap_typedescr=>typekind_packed act = cl_abap_typedescr=>describe_by_data( lv_amount )->type_kind ). ENDMETHOD. ENDCLASS. CLASS lcl_tenant DEFINITION. PUBLIC SECTION. INTERFACES {{p}}if_tenancy_check. ENDCLASS. CLASS lcl_tenant IMPLEMENTATION. METHOD {{p}}if_tenancy_check~check. ENDMETHOD. METHOD {{p}}if_tenancy_check~deposit. ENDMETHOD. ENDCLASS.