added interface tests

This commit is contained in:
eduardocopat 2016-12-21 16:03:27 +01:00
parent c0cb1f2a95
commit 56675067e4

View File

@ -1398,18 +1398,18 @@ CLASS ltd_fake_object_files IMPLEMENTATION.
ENDCLASS. ENDCLASS.
CLASS ltc_class_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. CLASS ltc_oo_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT .
PRIVATE SECTION. PROTECTED SECTION.
METHODS: DATA:
setup, mo_spy_oo_object TYPE REF TO ltd_spy_oo_object,
given_a_class_properties mo_fake_object_files TYPE REF TO ltd_fake_object_files,
mo_xml_input TYPE REF TO lcl_xml_input,
mo_xml_out TYPE REF TO lcl_xml_output,
mo_oo_object TYPE REF TO lif_object,
ms_item TYPE ty_item.
METHODS: when_deserializing
RAISING RAISING
lcx_exception, lcx_exception,
when_deserializing
RAISING
lcx_exception,
then_should_create_class,
then_it_should_generate_locals,
then_should_deserialize_source, then_should_deserialize_source,
given_the_descriptions given_the_descriptions
IMPORTING IMPORTING
@ -1419,21 +1419,77 @@ CLASS ltc_class_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURAT
then_shuld_update_descriptions then_shuld_update_descriptions
IMPORTING IMPORTING
it_descriptions TYPE ty_seocompotx_tt, it_descriptions TYPE ty_seocompotx_tt,
then_it_should_add_activation, then_it_should_add_activation.
ENDCLASS.
CLASS ltc_oo_test IMPLEMENTATION.
METHOD then_it_should_add_activation.
cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_item_to_activate
exp = ms_item
).
ENDMETHOD.
METHOD then_shuld_update_descriptions.
cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->mt_descriptions
exp = it_descriptions
).
cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_description_key
exp = ms_item-obj_name
).
ENDMETHOD.
METHOD given_the_descriptions.
mo_xml_out->add(
iv_name = 'DESCRIPTIONS'
ig_data = it_descriptions
).
ENDMETHOD.
METHOD then_should_deserialize_source.
cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->mt_source
exp = mo_fake_object_files->mt_sources
).
cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_deserialize_key
exp = ms_item-obj_name
).
ENDMETHOD.
METHOD when_deserializing.
CREATE OBJECT mo_xml_input
EXPORTING
iv_xml = mo_xml_out->render( ).
mo_oo_object->deserialize(
iv_package = 'package_name'
io_xml = mo_xml_input
).
ENDMETHOD.
ENDCLASS.
CLASS ltc_class_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
INHERITING FROM ltc_oo_test.
PRIVATE SECTION.
METHODS:
setup,
given_a_class_properties
RAISING
lcx_exception,
then_should_create_class,
then_it_should_generate_locals,
should_create_class FOR TESTING RAISING cx_static_check, should_create_class FOR TESTING RAISING cx_static_check,
should_generate_locals FOR TESTING RAISING cx_static_check, should_generate_locals FOR TESTING RAISING cx_static_check,
should_deserialize_source FOR TESTING RAISING cx_static_check, should_deserialize_source FOR TESTING RAISING cx_static_check,
should_update_descriptions FOR TESTING RAISING cx_static_check, should_update_descriptions FOR TESTING RAISING cx_static_check,
should_add_to_activation FOR TESTING RAISING cx_static_check. should_add_to_activation FOR TESTING RAISING cx_static_check.
DATA: DATA:
mo_spy_oo_object TYPE REF TO ltd_spy_oo_object, ms_class_properties TYPE vseoclass.
mo_fake_object_files TYPE REF TO ltd_fake_object_files,
mo_xml_input TYPE REF TO lcl_xml_input,
mo_xml_out TYPE REF TO lcl_xml_output,
mo_class TYPE REF TO lif_object,
ms_class_properties TYPE vseoclass,
ls_item TYPE ty_item.
ENDCLASS. ENDCLASS.
CLASS ltc_class_deserialization IMPLEMENTATION. CLASS ltc_class_deserialization IMPLEMENTATION.
@ -1443,19 +1499,19 @@ CLASS ltc_class_deserialization IMPLEMENTATION.
CREATE OBJECT mo_xml_out. CREATE OBJECT mo_xml_out.
lth_oo_factory_injector=>inject( mo_spy_oo_object ). lth_oo_factory_injector=>inject( mo_spy_oo_object ).
ls_item-devclass = 'package_name'. ms_item-devclass = 'package_name'.
ls_item-obj_name = 'zcl_class'. ms_item-obj_name = 'zcl_class'.
ls_item-obj_type = 'CLAS'. ms_item-obj_type = 'CLAS'.
CREATE OBJECT mo_class TYPE lcl_object_clas CREATE OBJECT mo_oo_object TYPE lcl_object_clas
EXPORTING EXPORTING
is_item = ls_item is_item = ms_item
iv_language = sy-langu. iv_language = sy-langu.
mo_class->mo_files = mo_fake_object_files. mo_oo_object->mo_files = mo_fake_object_files.
ENDMETHOD. ENDMETHOD.
METHOD should_create_class. METHOD should_create_class.
ms_class_properties-clsname = ls_item-obj_name. ms_class_properties-clsname = ms_item-obj_name.
given_a_class_properties( ). given_a_class_properties( ).
@ -1487,7 +1543,7 @@ CLASS ltc_class_deserialization IMPLEMENTATION.
given_a_class_properties( ). given_a_class_properties( ).
ls_description-clsname = ls_item-obj_name. ls_description-clsname = ms_item-obj_name.
ls_description-cmpname = 'a_method'. ls_description-cmpname = 'a_method'.
APPEND ls_description TO lt_descriptions. APPEND ls_description TO lt_descriptions.
given_the_descriptions( lt_descriptions ). given_the_descriptions( lt_descriptions ).
@ -1502,7 +1558,6 @@ CLASS ltc_class_deserialization IMPLEMENTATION.
when_deserializing( ). when_deserializing( ).
"Activation
then_it_should_add_activation( ). then_it_should_add_activation( ).
ENDMETHOD. ENDMETHOD.
@ -1513,20 +1568,7 @@ then_it_should_add_activation( ).
). ).
ENDMETHOD. ENDMETHOD.
METHOD when_deserializing.
CREATE OBJECT mo_xml_input
EXPORTING
iv_xml = mo_xml_out->render( ).
mo_class->deserialize(
iv_package = 'package_name'
io_xml = mo_xml_input
).
ENDMETHOD.
METHOD then_should_create_class. METHOD then_should_create_class.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_class_properties act = mo_spy_oo_object->ms_class_properties
exp = ms_class_properties exp = ms_class_properties
@ -1538,14 +1580,13 @@ then_it_should_add_activation( ).
act = mo_spy_oo_object->mv_package act = mo_spy_oo_object->mv_package
exp = 'package_name' exp = 'package_name'
). ).
ENDMETHOD. ENDMETHOD.
METHOD then_it_should_generate_locals. METHOD then_it_should_generate_locals.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_locals_key act = mo_spy_oo_object->ms_locals_key
exp = ls_item-obj_name exp = ms_item-obj_name
). ).
cl_abap_unit_assert=>assert_true( mo_spy_oo_object->mv_force ). cl_abap_unit_assert=>assert_true( mo_spy_oo_object->mv_force ).
@ -1569,46 +1610,102 @@ then_it_should_add_activation( ).
exp = mo_fake_object_files->mt_local_test_classes exp = mo_fake_object_files->mt_local_test_classes
). ).
ENDMETHOD. ENDMETHOD.
ENDCLASS.
CLASS ltc_interface_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
INHERITING FROM ltc_oo_test.
PRIVATE SECTION.
METHODS:
setup,
given_an_interface_properties
RAISING
lcx_exception,
then_should_create_interface,
create_interface FOR TESTING RAISING cx_static_check,
update_descriptions FOR TESTING RAISING cx_static_check,
add_to_activation FOR TESTING RAISING cx_static_check,
deserialize_source FOR TESTING RAISING cx_static_check.
DATA:
ms_interface_properties TYPE vseointerf.
ENDCLASS.
CLASS ltc_interface_deserialization IMPLEMENTATION.
METHOD setup.
CREATE OBJECT mo_fake_object_files.
CREATE OBJECT mo_spy_oo_object.
CREATE OBJECT mo_xml_out.
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
METHOD then_should_deserialize_source. ms_item-devclass = 'package_name'.
cl_abap_unit_assert=>assert_equals( ms_item-obj_name = 'zif_interface'.
act = mo_spy_oo_object->mt_source ms_item-obj_type = 'INTF'.
exp = mo_fake_object_files->mt_sources
).
cl_abap_unit_assert=>assert_equals( CREATE OBJECT mo_oo_object TYPE lcl_object_intf
act = mo_spy_oo_object->ms_deserialize_key EXPORTING
exp = ls_item-obj_name is_item = ms_item
). iv_language = sy-langu.
mo_oo_object->mo_files = mo_fake_object_files.
ENDMETHOD. ENDMETHOD.
METHOD create_interface.
ms_interface_properties-clsname = ms_item-obj_name.
given_an_interface_properties( ).
METHOD given_the_descriptions. when_deserializing( ).
then_should_create_interface( ).
ENDMETHOD.
METHOD update_descriptions.
DATA:
ls_description TYPE seocompotx,
lt_descriptions TYPE ty_seocompotx_tt.
given_an_interface_properties( ).
ls_description-clsname = ms_item-obj_name.
ls_description-cmpname = 'a_method'.
APPEND ls_description TO lt_descriptions.
given_the_descriptions( lt_descriptions ).
when_deserializing( ).
then_shuld_update_descriptions( lt_descriptions ).
ENDMETHOD.
METHOD add_to_activation.
given_an_interface_properties( ).
when_deserializing( ).
then_it_should_add_activation( ).
ENDMETHOD.
METHOD deserialize_source.
given_an_interface_properties( ).
when_deserializing( ).
then_should_deserialize_source( ).
ENDMETHOD.
METHOD given_an_interface_properties.
mo_xml_out->add( mo_xml_out->add(
iv_name = 'DESCRIPTIONS' iv_name = 'VSEOINTERF'
ig_data = it_descriptions ig_data = ms_interface_properties
). ).
ENDMETHOD. ENDMETHOD.
METHOD then_should_create_interface.
METHOD then_shuld_update_descriptions.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->mt_descriptions act = mo_spy_oo_object->ms_interface_properties
exp = it_descriptions exp = ms_interface_properties
). ).
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_true( mo_spy_oo_object->mv_overwrite ).
act = mo_spy_oo_object->ms_description_key
exp = ls_item-obj_name
).
ENDMETHOD.
METHOD then_it_should_add_activation.
cl_abap_unit_assert=>assert_equals( cl_abap_unit_assert=>assert_equals(
act = mo_spy_oo_object->ms_item_to_activate act = mo_spy_oo_object->mv_package
exp = ls_item exp = 'package_name'
). ).
ENDMETHOD. ENDMETHOD.