*"* use this source file for your ABAP unit test classes
CLASS LTCL_CELL DEFINITION FINAL FOR TESTING
  DURATION SHORT
  RISK LEVEL HARMLESS.


  PRIVATE SECTION.

    METHODS:
      SETUP.
    METHODS:
      TEST_1_NEIGHBOUR_DIES FOR TESTING RAISING CX_STATIC_CHECK,
      TEST_2_NEIGHBOURS_LIVES FOR TESTING RAISING CX_STATIC_CHECK,
      TEST_3_NEIGHBOURS_LIVES FOR TESTING RAISING CX_STATIC_CHECK,
      TEST_DEAD_CELL_3_NEIGHB_ALIVE FOR TESTING RAISING CX_STATIC_CHECK,
      test_dead_cell_2_neighb_dead FOR TESTING RAISING cx_static_check,
      test_dead_cell_4_neighb_dead FOR TESTING RAISING cx_static_check.


ENDCLASS.


CLASS LTCL_CELL IMPLEMENTATION.

  METHOD TEST_1_NEIGHBOUR_DIES.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_TRUE ).
    CELL->SET_LIVE_NEIGHBOURS( 1 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
        MSG = 'Zelle mit nur einem lebenden Nachbarn muss sterben'
        EXP = ABAP_FALSE
        ACT = CELL->CELL_SURVIVES( ) ).
  ENDMETHOD.

  METHOD TEST_2_NEIGHBOURS_LIVES.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_TRUE ).
    CELL->SET_LIVE_NEIGHBOURS( I_LIVE_NEIGHBOURS = 2 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
      MSG = 'Zelle mit zwei lebenden Nachbarn bleibt am Leben'
      EXP = ABAP_TRUE
      ACT = CELL->CELL_SURVIVES(  ) ).
  ENDMETHOD.

  METHOD TEST_3_NEIGHBOURS_LIVES.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_TRUE ).
    CELL->SET_LIVE_NEIGHBOURS( I_LIVE_NEIGHBOURS = 3 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
      MSG = 'Zelle mit drei lebenden Nachbarn bleibt am Leben'
      EXP = ABAP_TRUE
      ACT = CELL->CELL_SURVIVES(  ) ).
  ENDMETHOD.

  METHOD TEST_DEAD_CELL_3_NEIGHB_ALIVE.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_FALSE ).
    CELL->SET_LIVE_NEIGHBOURS( I_LIVE_NEIGHBOURS = 3 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
      MSG = 'Zelle mit drei lebenden Nachbarn bleibt am Leben'
      EXP = ABAP_TRUE
      ACT = CELL->CELL_SURVIVES(  ) ).
  ENDMETHOD.

  METHOD TEST_DEAD_CELL_2_NEIGHB_dead.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_FALSE ).
    CELL->SET_LIVE_NEIGHBOURS( I_LIVE_NEIGHBOURS = 2 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
      MSG = 'Tote Zelle mit zwei lebenden Nachbarn bleibt tot'
      EXP = ABAP_FALSE
      ACT = CELL->CELL_SURVIVES(  ) ).
  ENDMETHOD.

  METHOD TEST_DEAD_CELL_4_NEIGHB_dead.
    DATA(CELL) = NEW ZCL_GOL_15( ABAP_FALSE ).
    CELL->SET_LIVE_NEIGHBOURS( I_LIVE_NEIGHBOURS = 4 ).
    CL_ABAP_UNIT_ASSERT=>ASSERT_EQUALS(
      MSG = 'Tote Zelle mit vier lebenden Nachbarn bleibt tot'
      EXP = ABAP_FALSE
      ACT = CELL->CELL_SURVIVES(  ) ).
  ENDMETHOD.
  METHOD SETUP.

  ENDMETHOD.

ENDCLASS.
