ROUTINE-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.Assert FROM PROPATH.

CLASS unittests.gui.fillin.date.screen.DateParseCapture
INHERITS unittests.gui.fillin.date.screen.DateParseTestBase:
    
    METHOD PRIVATE VOID handleTest(INPUT spec AS CHARACTER):
       
       setScreenValue(spec) NO-ERROR.
       
       IF ERROR-STATUS:ERROR THEN
           DISPLAY "'" + spec + "' E" + STRING(ERROR-STATUS:GET-NUMBER(1)) FORMAT "x(60)".
       ELSE DO:
           DEFINE VARIABLE d AS DATE NO-UNDO.
           d = getInputValue().
           IF d = ? THEN
              DISPLAY "'" + spec + "' ?" FORMAT "x(60)".
           ELSE
               DISPLAY ("'" + spec + "' " + STRING(YEAR(d), "->>>>>9") + " " +
                     STRING(MONTH(d), ">9") + " " +
                     STRING(DAY(d), ">9")) FORMAT "x(60)".
       END.
    END METHOD.
       
   /**
    * Tests successful date string parse
    *
    * @param spec
    *        date string
    * @param expectedYear
    *        expected result year, not used when capturing
    * @param expectedMonth
    *        expected result month, not used when capturing
    * @param expectedDay
    *        expected result day, not used when capturing
    */
    METHOD OVERRIDE VOID handleTestSuccess(
       INPUT spec AS CHARACTER,
       INPUT expectedYear AS INTEGER,
       INPUT expectedMonth AS INTEGER,
       INPUT expectedDay AS INTEGER):
       
       handleTest(spec).
    END METHOD.
       
   /**
    * Tests successful date string parse to an unknown date value
    *
    * @param spec
    *        date string
    */
    METHOD OVERRIDE VOID handleTestUnknown(
       INPUT spec AS CHARACTER):
       
       handleTest(spec).
    END METHOD.

   /**
    * Tests date string parse failure
    *
    * @param spec
    *        date string
    * @param errorNo
    *        expected error number
    */
    METHOD OVERRIDE VOID handleTestFailure(
       INPUT spec AS CHARACTER,
       INPUT errorNo AS INTEGER):
       
       handleTest(spec).
    END METHOD.
    
    /**
     * Call all the tests in one go, capture result to a file
     */
    @Test.
    METHOD PUBLIC VOID captureAll():
       OUTPUT TO VALUE( "date_screen_value.txt" ).
    
       DISPLAY "today".
       SUPER:testToday().
       DISPLAY "now".
       SUPER:testNow().
       DISPLAY "UnknownValues".
       SUPER:testUnknownValues().
       MESSAGE "MdyFailures".
       SUPER:testMdyFailures().
       MESSAGE "MdySuccesses".
       SUPER:testMdySuccesses().
       MESSAGE "DmyFailures".
       SUPER:testDmyFailures().
       MESSAGE "DmySuccesses".
       SUPER:testDmySuccesses().
       MESSAGE "YmdFailures".
       SUPER:testYmdFailures().
       MESSAGE "YmdSuccesses".
       SUPER:testYmdSuccesses().
       MESSAGE "MydFailures".
       SUPER:testMydFailures().
       MESSAGE "MydSuccesses".
       SUPER:testMydSuccesses().
       MESSAGE "DymFailures".
       SUPER:testDymFailures().
       MESSAGE "DymSuccesses".
       SUPER:testDymSuccesses().
       MESSAGE "YdmFailures".
       SUPER:testYdmFailures().
       MESSAGE "YdmSuccesses".
       SUPER:testYdmSuccesses().
       
       OUTPUT CLOSE.
    END METHOD.

END CLASS.

